restrict conform.nvim format on save to only specific filetypes

This commit is contained in:
Fábio André Damas 2025-08-26 10:16:22 +01:00
parent 8f912a52df
commit e4d067b26d
2 changed files with 23 additions and 39 deletions

View file

@ -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,