diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua index cc922f1..94d5b6f 100644 --- a/lua/plugins/lsp.lua +++ b/lua/plugins/lsp.lua @@ -69,19 +69,19 @@ return { temp_dir = nil, update_in_insert = false, -- formatting on save - --on_attach = function(client, bufnr) - -- if client.supports_method("textDocument/formatting") then - -- vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr }) - -- vim.api.nvim_create_autocmd("BufWritePre", { - -- group = augroup, - -- buffer = bufnr, - -- callback = function() - -- vim.lsp.buf.format({ bufnr = bufnr }) - -- end, - -- }) - -- end - --end, - } -- end of setup + on_attach = function(client, bufnr) + if client.supports_method "textDocument/formatting" then + vim.api.nvim_clear_autocmds { group = augroup, buffer = bufnr } + vim.api.nvim_create_autocmd("BufWritePre", { + group = augroup, + buffer = bufnr, + callback = function() + vim.lsp.buf.format { bufnr = bufnr } + end, + }) + end + end, + } end, },