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)
|
vim.keymap.set("n", "<Leader>ac", vim.lsp.buf.code_action, opts)
|
||||||
|
|
||||||
if client.resolved_capabilities.document_formatting then
|
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", {
|
vim.api.nvim_create_autocmd("BufWritePre", {
|
||||||
group = au_id,
|
group = au_id,
|
||||||
callback = function()
|
callback = vim.lsp.buf.formatting_seq_sync,
|
||||||
vim.lsp.buf.formatting_seq_sync()
|
|
||||||
end,
|
|
||||||
buffer = bufnr,
|
buffer = bufnr,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue