restrict conform.nvim format on save to only specific filetypes
This commit is contained in:
parent
8f912a52df
commit
e4d067b26d
2 changed files with 23 additions and 39 deletions
|
|
@ -1,29 +1,3 @@
|
|||
local augroup = vim.api.nvim_create_augroup("LspFormatting", {})
|
||||
local format_on_save = function(client, bufnr)
|
||||
if client.supports_method("textDocument/formatting") then
|
||||
vim.api.nvim_clear_autocmds({
|
||||
group = augroup,
|
||||
buffer = bufnr,
|
||||
})
|
||||
vim.api.nvim_create_autocmd("BufWritePre", {
|
||||
group = augroup,
|
||||
buffer = bufnr,
|
||||
callback = function()
|
||||
-- prevents format from being included in the undo history
|
||||
-- this way the cursor doesn't jump around the file when
|
||||
-- undoing
|
||||
vim.cmd("silent! undojoin")
|
||||
|
||||
vim.lsp.buf.format({
|
||||
bufnr = bufnr,
|
||||
async = false,
|
||||
})
|
||||
end,
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
vim.diagnostic.config({
|
||||
virtual_lines = false,
|
||||
virtual_text = false,
|
||||
|
|
@ -91,9 +65,6 @@ return {
|
|||
local null_ls = require("null-ls")
|
||||
|
||||
null_ls.setup({
|
||||
on_attach = function(client, bufnr)
|
||||
format_on_save(client, bufnr)
|
||||
end,
|
||||
sources = {
|
||||
null_ls.builtins.diagnostics.dotenv_linter,
|
||||
null_ls.builtins.diagnostics.editorconfig_checker,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue