feat(nvim): allow disabling lsp formatters

This commit is contained in:
Price Hiller 2024-02-02 22:13:13 -06:00
parent 48c361dd51
commit ab0e7cbc13
Signed by: Price
SSH Key Fingerprint: SHA256:Y4S9ZzYphRn1W1kbJerJFO6GGsfu9O70VaBSxJO7dF8
2 changed files with 14 additions and 0 deletions

View File

@ -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()

View File

@ -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", {