diff --git a/lua/lazyvim/plugins/lsp/format.lua b/lua/lazyvim/plugins/lsp/format.lua index 7fca9d31..030561a6 100644 --- a/lua/lazyvim/plugins/lsp/format.lua +++ b/lua/lazyvim/plugins/lsp/format.lua @@ -5,7 +5,12 @@ local M = {} M.autoformat = true function M.toggle() - M.autoformat = not M.autoformat + if vim.b.autoformat == false then + vim.b.autoformat = nil + M.autoformat = true + else + M.autoformat = not M.autoformat + end if M.autoformat then Util.info("Enabled format on save", { title = "Format" }) else @@ -15,6 +20,9 @@ end function M.format() local buf = vim.api.nvim_get_current_buf() + if vim.b.autoformat == false then + return + end local ft = vim.bo[buf].filetype local have_nls = #require("null-ls.sources").get_available(ft, "NULL_LS_FORMATTING") > 0