summaryrefslogtreecommitdiffstats
path: root/usecases/desktop/development.nix
diff options
context:
space:
mode:
Diffstat (limited to 'usecases/desktop/development.nix')
-rw-r--r--usecases/desktop/development.nix39
1 files changed, 24 insertions, 15 deletions
diff --git a/usecases/desktop/development.nix b/usecases/desktop/development.nix
index 5d9697f..fad2596 100644
--- a/usecases/desktop/development.nix
+++ b/usecases/desktop/development.nix
@@ -13,15 +13,30 @@ let
13 13
14 inherit (pkgs.unstable.python3Packages) python-language-server; 14 inherit (pkgs.unstable.python3Packages) python-language-server;
15 15
16 luaFormat = inputs.self.lib.generators.lua { };
17
16in 18in
17{ 19{
18 options = with lib; { 20 options = with lib; with luaFormat.lib; {
19 vim.lsp = mkOption { 21 vim.lsp = mkOption {
20 description = '' 22 description = ''
21 Configure Neovim to use these LSP servers; 23 Configure Neovim to use these LSP servers;
22 ''; 24 '';
23 # TODO: change that to submodule with cmd, settings, capabilities, etc. 25 type = with types; attrsOf (submodule {
24 type = with types; attrsOf (listOf str); 26 freeformType = luaFormat.type;
27
28 options = {
29 capabilities = mkOption {
30 default = mkRaw "capabilities";
31 };
32 cmd = mkOption {
33 type = with types; listOf str;
34 };
35 on_attach = mkOption {
36 default = mkRaw "on_attach";
37 };
38 };
39 });
25 default = { }; 40 default = { };
26 }; 41 };
27 }; 42 };
@@ -46,24 +61,18 @@ in
46 ]; 61 ];
47 62
48 variables = { 63 variables = {
49 rust_analyzer_path = "'${rust-analyzer-unwrapped}/bin/rust-analyzer'"; 64 rust_analyzer_path = "${rust-analyzer-unwrapped}/bin/rust-analyzer";
50 }; 65 };
51 66
52 lsp = { 67 lsp = {
53 clangd = [ "${clang-tools}/bin/clangd" "--resource-dir=${clang}/resource-root" ]; 68 clangd.cmd = [ "${clang-tools}/bin/clangd" "--resource-dir=${clang}/resource-root" ];
54 elixirls = [ "${elixir_ls}/bin/elixir-ls" ]; 69 elixirls.cmd = [ "${elixir_ls}/bin/elixir-ls" ];
55 pyls = [ "${python-language-server}/bin/pyls" ]; 70 pyls.cmd = [ "${python-language-server}/bin/pyls" ];
56 }; 71 };
57 72
58 luaConfig = with lib; let 73 luaConfig = with lib; let
59 toLua = list: "{ ${concatMapStringsSep ", " (elem: "'${escape [ "'" ] elem}'") list} }"; 74 toLua = luaFormat.generate;
60 lspconfigFor = name: cmd: '' 75 lspconfigFor = name: settings: "lspconfig['${name}'].setup ${toLua settings}";
61 lspconfig["${name}"].setup {
62 capabilities = capabilities,
63 cmd = ${toLua cmd},
64 on_attach = on_attach,
65 }
66 '';
67 lspconfig = concatStringsSep 76 lspconfig = concatStringsSep
68 "\n" 77 "\n"
69 (mapAttrsToList lspconfigFor config.vim.lsp); 78 (mapAttrsToList lspconfigFor config.vim.lsp);