feat(lsp): allow disabling autoformat for certain buffers

This commit is contained in:
Folke Lemaitre 2023-02-07 23:15:10 +01:00
parent 79b4d67357
commit 52b34ce3c3
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040

View file

@ -5,7 +5,12 @@ local M = {}
M.autoformat = true
function M.toggle()
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