Fix lsp formatting autocommand
parent
421c02feec
commit
939a9bca01
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue