fix(lsp): set auto format on save - clear autocmds

This commit is contained in:
Matthew Leong 2023-01-09 13:34:41 -08:00
parent f87b823625
commit c58d5fb85a

View file

@ -29,10 +29,14 @@ function M.on_attach(client, bufnr)
filetype_pattern = '*' filetype_pattern = '*'
end end
vim.api.nvim_clear_autocmds({
group = group,
buffer = bufnr,
})
-- autocommand for format on save with specified filetype(s) -- autocommand for format on save with specified filetype(s)
vim.api.nvim_create_autocmd(string.format('BufWritePre %s', filetype_pattern), { vim.api.nvim_create_autocmd(string.format('BufWritePre %s', filetype_pattern), {
callback = function() callback = function()
require('cosmic.utils.lsp').format() require('cosmic.utils.lsp').format(bufnr)
end, end,
buffer = bufnr, buffer = bufnr,
group = group, group = group,