Move formatting configuration to separate file

This commit is contained in:
Sonny Bakker 2025-03-18 21:51:14 +01:00
parent 6adb1f506f
commit 6d801bcb4e
4 changed files with 26 additions and 25 deletions

View file

@ -187,27 +187,3 @@ vim.diagnostic.config {
end
},
}
local enable_formatting = os.getenv("enable_formatting") == 'true';
-- format buffers before saving for specific LSPs
if (enable_formatting) then
vim.api.nvim_create_autocmd('LspAttach', {
group = vim.api.nvim_create_augroup('lsp', { clear = true }),
callback = function(args)
local client = vim.lsp.get_client_by_id(args.data.client_id)
if client.server_capabilities.documentFormattingProvider then
vim.api.nvim_create_autocmd('BufWritePre', {
buffer = args.buf,
callback = function()
vim.lsp.buf.format {
async = false,
id = args.data.client_id
}
end,
})
end
end
})
end