121 lines
3.4 KiB
Nix
121 lines
3.4 KiB
Nix
{
|
|
# Feature flags
|
|
typescript ? false,
|
|
haskell ? false,
|
|
python ? false,
|
|
rust ? false,
|
|
nix ? true,
|
|
|
|
# Build context
|
|
pkgs,
|
|
lib
|
|
}:
|
|
|
|
with lib;
|
|
with pkgs;
|
|
|
|
let semantic-tokens =
|
|
let mk = (name: value: ''
|
|
[[semantic_tokens]]
|
|
token = "${name}"
|
|
face = "${value}"
|
|
''); in concatStringsSep "\n" (mapAttrsToList mk {
|
|
"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";
|
|
});
|
|
|
|
kak-lsp-config-text =
|
|
(optionalString (rust || haskell) semantic-tokens)
|
|
++ (optionalString rust ''
|
|
[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
|
|
'')
|
|
++ (optionalString nix ''
|
|
[language.nix]
|
|
filetypes = [ "nix" ]
|
|
roots = [ "flake.nix", "shell.nix", ".git", ".hg" ]
|
|
command = "rnix-lsp"
|
|
'')
|
|
++ (optionalString haskell ''
|
|
[language.haskell]
|
|
filetypes = [ "haskell" ]
|
|
roots = [ "Setup.hs", "stack.yaml", "*.cabal" ]
|
|
command = "haskell-language-server-wrapper"
|
|
args = [ "--lsp" ]
|
|
'')
|
|
++ (optionalString python ''
|
|
[language.python]
|
|
filetypes = [ "python" ]
|
|
roots = [ "setup.py", ".git", ".hg" ]
|
|
command = "pylsp"
|
|
'')
|
|
++ (optionalString typescript ''
|
|
[language.typescript]
|
|
filetypes = ["typescript", "javascript"]
|
|
roots = ["package.json"]
|
|
command = "rslint-lsp"
|
|
'');
|
|
|
|
kak-lsp-config = (pkgs.writeTextFile (rec {
|
|
name = "kak-lsp.toml";
|
|
destination = "/share/kak-lsp/${name}";
|
|
text = kak-lsp-config-text;
|
|
}));
|
|
|
|
in (symlinkJoin {
|
|
|
|
paths = with kakounePlugins; [
|
|
|
|
# The language server client
|
|
kak-lsp
|
|
|
|
# Overwrite kak-lsp.toml
|
|
kak-lsp-config
|
|
|
|
] ++ (optional nix rnix-lsp)
|
|
++ (optional typescript rslint)
|
|
++ (optional haskell haskell-language-server)
|
|
++ (optional python python39Packages.python-lsp-server)
|
|
++ (optional rust rust-analyzer);
|
|
|
|
name = "kak-lsp-${kak-lsp.version}";
|
|
nativeBuildInputs = [ makeWrapper ];
|
|
postBuild = ''
|
|
wrapProgram $out/bin/kak-lsp --add-flags "--config $out/share/kak-lsp/kak-lsp.toml"
|
|
'';
|
|
})
|