summaryrefslogtreecommitdiff
path: root/config/plugins/lsp.nix
blob: c2648db1cf2d409128587b212d74ae9dc508abc9 (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
{lib, ...}: {
  plugins.lsp = {
    enable = true;

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

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

    servers = let
      withDefaultOpts = lib.genAttrs [
        "bashls"
        "lua-ls"
        "nil_ls"
      ] (_: {enable = true;});

      optionalOpts = {
        enable = true;
        installLanguageServer = false;
        autostart = false;
      };

      optional = lib.genAttrs [
        "clangd"
        "eslint"
        "pyright"
        "rust-analyzer"
        "tsserver"
      ] (_: optionalOpts);
    in
      withDefaultOpts
      // optional
      // {
        rust-analyzer =
          optionalOpts
          // {
            installRustc = false;
            installCargo = false;
          };
      };
  };
}