From 7e706515a85f9a8931c8bdd14440ac9419405061 Mon Sep 17 00:00:00 2001 From: jdhao Date: Thu, 19 Dec 2024 23:43:40 +0100 Subject: [PATCH] silently format lua file using stylua We need to disable the mapping set for LSP, otherwise the mapping set in lua.vim will be overridden. --- after/ftplugin/lua.vim | 2 +- lua/config/lsp.lua | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/after/ftplugin/lua.vim b/after/ftplugin/lua.vim index cb1abf54..1c60d66a 100644 --- a/after/ftplugin/lua.vim +++ b/after/ftplugin/lua.vim @@ -4,4 +4,4 @@ set formatoptions-=r nnoremap :luafile % -nnoremap f !stylua % +nnoremap f silent !stylua % diff --git a/lua/config/lsp.lua b/lua/config/lsp.lua index 87d88fc5..f2c8492c 100644 --- a/lua/config/lsp.lua +++ b/lua/config/lsp.lua @@ -50,7 +50,7 @@ local custom_attach = function(client, bufnr) end, { desc = "list workspace folder" }) -- Set some key bindings conditional on server capabilities - if client.server_capabilities.documentFormattingProvider then + if client.server_capabilities.documentFormattingProvider and client.name ~= "lua_ls" then map({ "n", "x" }, "f", vim.lsp.buf.format, { desc = "format code" }) end