summaryrefslogtreecommitdiff
path: root/config/plugins/lsp.nix
blob: 0b8e3cdf58682aa45ea5f1de8e4e30090663a5ef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
{
  plugins.lsp = {
    enable = true;

    # nil-ls wants dynamicRegistration
    capabilities = ''
      capabilities = vim.tbl_deep_extend(
       	"force",
       	vim.lsp.protocol.make_client_capabilities(),
       	require("cmp_nvim_lsp").default_capabilities(),
       	{ workspace = { didChangeWatchedFiles = { dynamicRegistration = true } } }
       )
    '';

    keymaps = {
      diagnostic = {
        "<leader>e" = "open_float";
        "[d" = "goto_prev";
        "]d" = "goto_next";
        "<leader>u" = "setloclist";
      };

      lspBuf = {
        "<leader>ca" = "code_action";
      };
    };

    servers = let
      enable = {enable = true;};

      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;
    };
  };
}