Fix lsp formatting autocommand

main
Ensar Sarajčić 2022-05-19 11:19:32 +02:00
parent 421c02feec
commit 939a9bca01
1 changed files with 3 additions and 4 deletions

View File

@ -19,12 +19,11 @@ local function on_attach(client, bufnr)
vim.keymap.set("n", "<Leader>ac", vim.lsp.buf.code_action, opts)
if client.resolved_capabilities.document_formatting then
local au_id = vim.api.nvim_create_augroup("LspFormatting", {})
local au_id = vim.api.nvim_create_augroup("LspFormatting", { clear = false })
vim.api.nvim_clear_autocmds({ buffer = bufnr, group = au_id })
vim.api.nvim_create_autocmd("BufWritePre", {
group = au_id,
callback = function()
vim.lsp.buf.formatting_seq_sync()
end,
callback = vim.lsp.buf.formatting_seq_sync,
buffer = bufnr,
})
end