From cff0a2cf5b11165caf08e76ac8149777bf5b19a2 Mon Sep 17 00:00:00 2001 From: Riley Apeldoorn Date: Sun, 23 Jan 2022 17:22:34 +0100 Subject: [PATCH] [kak]: Split some of the config into a separate file --- modules/kak/default.nix | 94 ++--------------------------------------- modules/kak/lsp.nix | 90 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 93 insertions(+), 91 deletions(-) create mode 100644 modules/kak/lsp.nix diff --git a/modules/kak/default.nix b/modules/kak/default.nix index 67f1849..3cd823c 100644 --- a/modules/kak/default.nix +++ b/modules/kak/default.nix @@ -122,72 +122,6 @@ let kakrc = pkgs.writeTextFile (rec { inherit lib pkgs; }); - # Config for kak-lsp - kak-lsp-config = pkgs.writeTextFile (rec { - name = "kak-lsp.toml"; - destination = "/share/kak-lsp/${name}"; - text = let semTok = (name: value: '' - [[semantic_tokens]] - token = "${name}" - face = "${value}" - ''); in '' - - [language.rust] - filetypes = [ "rust" ] - roots = [ "Cargo.toml" ] - command = "rust-analyzer" - [language.rust.settings.rust-analyzer] - semanticTokens = true - diagnostics.enabled = [ "unresolved-proc-macro" ] - cargo.loadOutDirsFromCheck = true - procMacro.enable = false - - [language.haskell] - filetypes = [ "haskell" ] - roots = [ "Setup.hs", "stack.yaml", "*.cabal" ] - command = "haskell-language-server-wrapper" - args = [ "--lsp" ] - - [language.nix] - filetypes = [ "nix" ] - roots = [ "flake.nix", "shell.nix", ".git", ".hg" ] - command = "rnix-lsp" - - ${lib.concatStringsSep "\n" (lib.mapAttrsToList semTok { - "enumMember" = "variant"; - "enum" = "enum"; - "union" = "union"; - "struct" = "struct"; - "typeAlias" = "alias"; - "builtinType" = "primitive"; - "trait" = "trait"; - "interface" = "trait"; - "method" = "method"; - "function" = "function"; - "namespace" = "module"; - "boolean" = "literal"; - "character" = "literal"; - "number" = "literal"; - "string" = "string"; - "keyword" = "keyword"; - "documentation" = "comment"; - "comment" = "comment"; - "escapeSequence" = "format"; - "formatSpecifier" = "format"; - "operator" = "operator"; - "arithmetic" = "operator"; - "bitwise" = "operator"; - "comparison" = "operator"; - "logical" = "operator"; - "macro" = "macro"; - "lifetime" = "lifetime"; - "variable" = "variable"; - "attribute" = "attribute"; - "punctuation" = "punctuation"; - }) } - ''; - }); - in with lib; { options.riley = { @@ -204,31 +138,9 @@ in with lib; { # Custom config kakrc - ] ++ (lib.optionals config.riley.kak.ide [ - - # Kakoune language server support - (symlinkJoin { - paths = with kakounePlugins; [ - - # The language server client - kak-lsp - - # Include default language servers - rnix-lsp - haskell-language-server - - # Overwrite kak-lsp.toml - kak-lsp-config - - ]; - name = "kak-lsp-${kak-lsp.version}"; - nativeBuildInputs = [ makeWrapper ]; - postBuild = '' - wrapProgram $out/bin/kak-lsp --add-flags "--config $out/share/kak-lsp/kak-lsp.toml" - ''; - }) - - ]) ++ colors; + ] ++ (lib.optionals config.riley.kak.ide (import ./lsp.nix { + inherit pkgs lib config; + })) ++ colors; }) ]; diff --git a/modules/kak/lsp.nix b/modules/kak/lsp.nix new file mode 100644 index 0000000..16541dc --- /dev/null +++ b/modules/kak/lsp.nix @@ -0,0 +1,90 @@ +{ config, pkgs, lib, ... }: with pkgs; + +let lsp-config = (writeTextFile (rec { + name = "kak-lsp.toml"; + destination = "/share/kak-lsp/${name}"; + text = let semTok = (name: value: '' + [[semantic_tokens]] + token = "${name}" + face = "${value}" + ''); in '' + + [language.rust] + filetypes = [ "rust" ] + roots = [ "Cargo.toml" ] + command = "rust-analyzer" + [language.rust.settings.rust-analyzer] + semanticTokens = true + diagnostics.enabled = [ "unresolved-proc-macro" ] + cargo.loadOutDirsFromCheck = true + procMacro.enable = false + + [language.haskell] + filetypes = [ "haskell" ] + roots = [ "Setup.hs", "stack.yaml", "*.cabal" ] + command = "haskell-language-server-wrapper" + args = [ "--lsp" ] + + [language.nix] + filetypes = [ "nix" ] + roots = [ "flake.nix", "shell.nix", ".git", ".hg" ] + command = "rnix-lsp" + + ${lib.concatStringsSep "\n" (lib.mapAttrsToList semTok { + "enumMember" = "variant"; + "enum" = "enum"; + "union" = "union"; + "struct" = "struct"; + "typeAlias" = "alias"; + "builtinType" = "primitive"; + "trait" = "trait"; + "interface" = "trait"; + "method" = "method"; + "function" = "function"; + "namespace" = "module"; + "boolean" = "literal"; + "character" = "literal"; + "number" = "literal"; + "string" = "string"; + "keyword" = "keyword"; + "documentation" = "comment"; + "comment" = "comment"; + "escapeSequence" = "format"; + "formatSpecifier" = "format"; + "operator" = "operator"; + "arithmetic" = "operator"; + "bitwise" = "operator"; + "comparison" = "operator"; + "logical" = "operator"; + "macro" = "macro"; + "lifetime" = "lifetime"; + "variable" = "variable"; + "attribute" = "attribute"; + "punctuation" = "punctuation"; + }) } + ''; + })); + +in [ + # Kakoune language server support + (symlinkJoin { + paths = with kakounePlugins; [ + + # The language server client + kak-lsp + + # Include default language servers + rnix-lsp + haskell-language-server + + # Overwrite kak-lsp.toml + lsp-config + + ]; + name = "kak-lsp-${kak-lsp.version}"; + nativeBuildInputs = [ makeWrapper ]; + postBuild = '' + wrapProgram $out/bin/kak-lsp --add-flags "--config $out/share/kak-lsp/kak-lsp.toml" + ''; + }) +]