From ae9136a14ae0b0fe91faad59b23d3a532ca84ed5 Mon Sep 17 00:00:00 2001 From: seth Date: Sun, 31 Dec 2023 08:32:06 -0500 Subject: lsp: use more native lsp features over efm --- config/plugins/lsp.nix | 86 ++++++++++++++++++++++++++++++-------------------- 1 file changed, 52 insertions(+), 34 deletions(-) (limited to 'config/plugins/lsp.nix') diff --git a/config/plugins/lsp.nix b/config/plugins/lsp.nix index c2648db..0b8e3cd 100644 --- a/config/plugins/lsp.nix +++ b/config/plugins/lsp.nix @@ -1,13 +1,15 @@ -{lib, ...}: { +{ plugins.lsp = { enable = true; + # nil-ls wants dynamicRegistration capabilities = '' capabilities = vim.tbl_deep_extend( - "force", - require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities()), - { workspace = { didChangeWatchedFiles = { dynamicRegistration = true } } } - ) + "force", + vim.lsp.protocol.make_client_capabilities(), + require("cmp_nvim_lsp").default_capabilities(), + { workspace = { didChangeWatchedFiles = { dynamicRegistration = true } } } + ) ''; keymaps = { @@ -17,38 +19,54 @@ "]d" = "goto_next"; "u" = "setloclist"; }; + + lspBuf = { + "ca" = "code_action"; + }; }; servers = let - withDefaultOpts = lib.genAttrs [ - "bashls" - "lua-ls" - "nil_ls" - ] (_: {enable = true;}); - - optionalOpts = { - enable = true; - installLanguageServer = false; - autostart = false; - }; + enable = {enable = true;}; - optional = lib.genAttrs [ - "clangd" - "eslint" - "pyright" - "rust-analyzer" - "tsserver" - ] (_: optionalOpts); - in - withDefaultOpts - // optional - // { - rust-analyzer = - optionalOpts - // { - installRustc = false; - installCargo = false; - }; - }; + optional = + enable + // { + installLanguageServer = false; + autostart = false; + }; + in { + bashls = enable; + clangd = optional; + denols = optional; + eslint = optional; + + lua-ls = enable; + + nil_ls = + enable + // { + settings.formatting.command = ["alejandra"]; + }; + + pyright = optional; + ruff-lsp = + optional + // { + # let pyright handle it + onAttach.function = '' + client.server_capabilities.hoverProvider = false + ''; + }; + + rust-analyzer = + optional + // { + installRustc = false; + installCargo = false; + settings.check.command = "clippy"; + }; + + tsserver = optional; + }; }; } -- cgit v1.2.3