mirror of
https://github.com/LazyVim/LazyVim.git
synced 2025-07-10 17:34:34 +02:00
feat(lsp): allow disabling autoformat for certain buffers
This commit is contained in:
parent
79b4d67357
commit
52b34ce3c3
1 changed files with 9 additions and 1 deletions
|
@ -5,7 +5,12 @@ local M = {}
|
||||||
M.autoformat = true
|
M.autoformat = true
|
||||||
|
|
||||||
function M.toggle()
|
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
|
if M.autoformat then
|
||||||
Util.info("Enabled format on save", { title = "Format" })
|
Util.info("Enabled format on save", { title = "Format" })
|
||||||
else
|
else
|
||||||
|
@ -15,6 +20,9 @@ end
|
||||||
|
|
||||||
function M.format()
|
function M.format()
|
||||||
local buf = vim.api.nvim_get_current_buf()
|
local buf = vim.api.nvim_get_current_buf()
|
||||||
|
if vim.b.autoformat == false then
|
||||||
|
return
|
||||||
|
end
|
||||||
local ft = vim.bo[buf].filetype
|
local ft = vim.bo[buf].filetype
|
||||||
local have_nls = #require("null-ls.sources").get_available(ft, "NULL_LS_FORMATTING") > 0
|
local have_nls = #require("null-ls.sources").get_available(ft, "NULL_LS_FORMATTING") > 0
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue