From ab0e7cbc133b8fba2ea6c3e100b0d8e77728c04b Mon Sep 17 00:00:00 2001 From: Price Hiller Date: Fri, 2 Feb 2024 22:13:13 -0600 Subject: [PATCH] feat(nvim): allow disabling lsp formatters --- dots/.config/nvim/lua/plugins/configs/formatter.lua | 1 + dots/.config/nvim/lua/plugins/configs/lsp.lua | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/dots/.config/nvim/lua/plugins/configs/formatter.lua b/dots/.config/nvim/lua/plugins/configs/formatter.lua index d1181fa4..70cc725e 100644 --- a/dots/.config/nvim/lua/plugins/configs/formatter.lua +++ b/dots/.config/nvim/lua/plugins/configs/formatter.lua @@ -14,6 +14,7 @@ return { end, -- I know this is a lie below, but I'm used to the key being LSP bound, so fuck it desc = "LSP: Format", + mode = { "v", "n" } }, }, opts = function() diff --git a/dots/.config/nvim/lua/plugins/configs/lsp.lua b/dots/.config/nvim/lua/plugins/configs/lsp.lua index 089be8cf..7bf4bf40 100644 --- a/dots/.config/nvim/lua/plugins/configs/lsp.lua +++ b/dots/.config/nvim/lua/plugins/configs/lsp.lua @@ -5,7 +5,20 @@ local function on_attach(client, bufnr) title = "LSP", }) + local function disable_format_capability(capabilities) + capabilities.documentFormattingProvider = false + capabilities.documentRangeFormattingProvider = false + end + local ignored_fmt_lsps = { + "lua_ls" + } local capabilities = client.server_capabilities + -- vim.notify(vim.inspect(capabilities)) + for _, lsp_name in ipairs(ignored_fmt_lsps) do + if client.name == lsp_name then + disable_format_capability(capabilities) + end + end -- Enable inlay hints if the language server provides them if capabilities.inlayHintProvider then vim.api.nvim_create_autocmd("InsertEnter", {