feat(lsp): allow disabling autoformat for certain buffers
This commit is contained in:
1 file changed
+9
-1
@@ -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
|
||||
|
||||
|
||||
Reference in new issue
Block a user