From 939a9bca01ab315f5c69cf029a95ddb5e4c5b61b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ensar=20Saraj=C4=8Di=C4=87?= Date: Thu, 19 May 2022 11:19:32 +0200 Subject: [PATCH] Fix lsp formatting autocommand --- symlinks/config/nvim/lua/esensar/lsp/server_config.lua | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/symlinks/config/nvim/lua/esensar/lsp/server_config.lua b/symlinks/config/nvim/lua/esensar/lsp/server_config.lua index 33af17b..dc868a3 100644 --- a/symlinks/config/nvim/lua/esensar/lsp/server_config.lua +++ b/symlinks/config/nvim/lua/esensar/lsp/server_config.lua @@ -19,12 +19,11 @@ local function on_attach(client, bufnr) vim.keymap.set("n", "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