Skip to content

Commit

Permalink
Add language servers metadata
Browse files Browse the repository at this point in the history
thomasjm committed Apr 16, 2024
1 parent d434f60 commit ae60440
Showing 29 changed files with 177 additions and 50 deletions.
2 changes: 2 additions & 0 deletions codedown/uiMetadata.nix
Original file line number Diff line number Diff line change
@@ -31,6 +31,8 @@ rec {
settings_schema = contents.settingsSchema;
}) // (lib.optionalAttrs (contents ? "modes") {
inherit (contents) modes;
}) // (lib.optionalAttrs (contents ? "languageServerNames") {
inherit (contents) languageServerNames;
});

mkChannelUiMetadata = name: channel: channel // {
4 changes: 3 additions & 1 deletion languages/bash/default.nix
Original file line number Diff line number Diff line change
@@ -60,14 +60,15 @@ lib.listToAttrs (map (x:
}@args:
let
settingsToUse = (common.makeDefaultSettings settingsSchema) // settings;
languageServers = chooseLanguageServers settingsToUse x;
in symlinkJoin {
name = "bash";

paths = [
(callPackage ./kernel.nix { inherit attrs extensions; })
(callPackage ./man-with-pages.nix {})
]
++ (chooseLanguageServers settingsToUse x)
++ languageServers
;

passthru = {
@@ -78,6 +79,7 @@ lib.listToAttrs (map (x:
inherit attrs extensions;
code_mirror_mode = "shell";
};
languageServerNames = map (x: x.languageServerName) languageServers;
};
}
) {};
11 changes: 9 additions & 2 deletions languages/bash/language_server_bash/default.nix
Original file line number Diff line number Diff line change
@@ -29,10 +29,17 @@ let
--suffix PATH ':' ${shellcheck}/bin \
--set SHELLCHECK_PATH ${shellcheck}/bin/shellcheck
'';

languageServerName = "bash-language-server";

passthru = {
inherit languageServerName;
};

in

common.writeTextDirWithMeta bashLanguageServerWithMan.meta "lib/codedown/language-servers/bash-${kernelName}-bash-language-server.yaml" (lib.generators.toYAML {} [{
name = "bash-language-server";
common.writeTextDirWithMetaAndPassthru bashLanguageServerWithMan.meta passthru "lib/codedown/language-servers/bash-${kernelName}-bash-language-server.yaml" (lib.generators.toYAML {} [{
name = languageServerName;
version = bashLanguageServer.version;
extensions = ["sh" "bash"];
notebook_suffix = ".bash";
4 changes: 3 additions & 1 deletion languages/clojure/default.nix
Original file line number Diff line number Diff line change
@@ -75,13 +75,14 @@ listToAttrs (map (x:
}:
let
settingsToUse = (common.makeDefaultSettings settingsSchema) // settings;
languageServers = chooseLanguageServers settingsToUse x;
in symlinkJoin {
name = "clojure";
paths = [
(callPackage ./kernel.nix { inherit attrs extensions version; })
clojure
]
++ (chooseLanguageServers settingsToUse x)
++ languageServers
;

passthru = {
@@ -93,6 +94,7 @@ listToAttrs (map (x:
inherit attrs extensions;
code_mirror_mode = "clojure";
};
languageServerNames = map (x: x.languageServerName) languageServers;
};
}
) {}
10 changes: 8 additions & 2 deletions languages/clojure/language-server.nix
Original file line number Diff line number Diff line change
@@ -9,10 +9,16 @@
let
common = callPackage ../common.nix {};

languageServerName = "clojure-lsp";

passthru = {
inherit languageServerName;
};

in

common.writeTextDirWithMeta clojure-lsp.meta "lib/codedown/language-servers/clojre-${kernelName}-clojure-lsp.yaml" (lib.generators.toYAML {} [{
name = "clojure-lsp";
common.writeTextDirWithMetaAndPassthru clojure-lsp.meta passthru "lib/codedown/language-servers/clojre-${kernelName}-clojure-lsp.yaml" (lib.generators.toYAML {} [{
name = languageServerName;
version = clojure-lsp.version;
display_name = "Clojure LSP";
description = clojure-lsp.meta.description or "Clojure & ClojureScript Language Server (LSP) implementation";
4 changes: 4 additions & 0 deletions languages/common.nix
Original file line number Diff line number Diff line change
@@ -44,6 +44,10 @@ rec {
inherit meta;
});

writeTextDirWithMetaAndPassthru = meta: passthru: path: text: (writeTextDir path text).overrideAttrs (old: {
inherit meta passthru;
});

writeShellScriptBinWithMeta = meta: path: text: (writeTextDir path text).overrideAttrs (old: {
inherit meta;
});
1 change: 1 addition & 0 deletions languages/cpp/default.nix
Original file line number Diff line number Diff line change
@@ -111,6 +111,7 @@ if cling == null then {} else
code_mirror_mode = "clike";
code_mirror_mime_type = "text/x-c++src";
};
languageServerNames = [];
};
}
) {};
4 changes: 3 additions & 1 deletion languages/go/default.nix
Original file line number Diff line number Diff line change
@@ -64,6 +64,7 @@ listToAttrs (map (x:
}@args:
let
settingsToUse = (common.makeDefaultSettings settingsSchema) // settings;
languageServers = chooseLanguageServers settingsToUse go attrs x;
in symlinkJoin {
name = "go";
paths = [
@@ -73,7 +74,7 @@ listToAttrs (map (x:
})
go
]
++ (chooseLanguageServers settingsToUse go attrs x)
++ languageServers
;

passthru = {
@@ -85,6 +86,7 @@ listToAttrs (map (x:
inherit attrs extensions;
code_mirror_mode = "go";
};
languageServerNames = map (x: x.languageServerName) languageServers;
};
}
) {};
10 changes: 8 additions & 2 deletions languages/go/language-server-gopls.nix
Original file line number Diff line number Diff line change
@@ -23,10 +23,16 @@ let
--set GOPATH ${go}/share/go
'';

languageServerName = "gopls";

passthru = {
inherit languageServerName;
};

in

common.writeTextDirWithMeta gopls.meta "lib/codedown/language-servers/go-${kernelName}-gopls.yaml" (lib.generators.toYAML {} [{
name = "gopls";
common.writeTextDirWithMetaAndPassthru gopls.meta passthru "lib/codedown/language-servers/go-${kernelName}-gopls.yaml" (lib.generators.toYAML {} [{
name = languageServerName;
version = gopls.version;
display_name = "gopls";
description = gopls.meta.description;
6 changes: 4 additions & 2 deletions languages/haskell/default.nix
Original file line number Diff line number Diff line change
@@ -20,7 +20,7 @@ let
chooseLanguageServers = settings: snapshot: ghc: kernelName:
[]
++ lib.optionals (common.isTrue settings "lsp.haskell-language-server.enable" && hasHlsSupport ghc.version)
[((callPackage ./language-server-hls/hls.nix {}) snapshot ghc kernelName (common.focusSettings "lsp.haskell-language-server." settings))]
[((callPackage ./language-server-hls {}) snapshot ghc kernelName (common.focusSettings "lsp.haskell-language-server." settings))]
;

compilers = callPackage ./compilers.nix {
@@ -85,6 +85,7 @@ listToAttrs (mapAttrsToList (compilerName: snapshot:
++ (map (x: builtins.getAttr x ps) packages)
++ (if (common.isTrue settingsToUse "lsp.haskell-language-server.enable") then [ps.haskell-language-server] else [])
);
languageServers = chooseLanguageServers settingsToUse snapshot ghc meta.baseName;

in symlinkJoin {
name = meta.baseName;
@@ -105,7 +106,7 @@ listToAttrs (mapAttrsToList (compilerName: snapshot:

ghc
]
++ (chooseLanguageServers settingsToUse snapshot ghc meta.baseName)
++ languageServers
;

passthru = {
@@ -117,6 +118,7 @@ listToAttrs (mapAttrsToList (compilerName: snapshot:
inherit attrs extensions;
code_mirror_mode = "haskell";
};
languageServerNames = map (x: x.languageServerName) languageServers;
};
}
) {}
16 changes: 12 additions & 4 deletions languages/haskell/language-server-hls/config.nix
Original file line number Diff line number Diff line change
@@ -33,8 +33,16 @@ let
--suffix PATH ':' ${lib.makeBinPath [coreutils findutils gnused]}
'';

config = raw: {
name = "haskell-language-server${if raw then "-raw" else ""}";
raw = false;

languageServerName = "haskell-language-server${if raw then "-raw" else ""}";

passthru = {
inherit languageServerName;
};

config = {
name = languageServerName;
version = haskell-language-server.version;
display_name = "Haskell Language Server";
description = haskell-language-server.meta.description;
@@ -59,6 +67,6 @@ let

in

common.writeTextDirWithMeta haskell-language-server.meta "lib/codedown/language-servers/haskell-${kernelName}-hls.yaml" (lib.generators.toYAML {} [
(config false)
common.writeTextDirWithMetaAndPassthru haskell-language-server.meta passthru "lib/codedown/language-servers/haskell-${kernelName}-hls.yaml" (lib.generators.toYAML {} [
config
])
5 changes: 4 additions & 1 deletion languages/julia/default.nix
Original file line number Diff line number Diff line change
@@ -143,6 +143,8 @@ mapAttrs (attr: value:
++ packages
++ lib.optionals (common.isTrue settingsToUse "lsp.LanguageServer.enable") ["LanguageServer" "SymbolServer"]
);

languageServers = chooseLanguageServers settingsToUse attrs attr julia;
in
symlinkJoin {
name = attr;
@@ -151,7 +153,7 @@ mapAttrs (attr: value:
(callPackage ./kernel.nix { inherit julia python attrs extensions displayName; })
julia
]
++ (chooseLanguageServers settingsToUse attrs attr julia)
++ languageServers
;

passthru = {
@@ -162,6 +164,7 @@ mapAttrs (attr: value:
inherit attrs extensions;
code_mirror_mode = "julia";
};
languageServerNames = map (x: x.languageServerName) languageServers;
};
}
) {}
10 changes: 8 additions & 2 deletions languages/julia/language-server-LanguageServer.nix
Original file line number Diff line number Diff line change
@@ -15,10 +15,16 @@ let

juliaIndices = callPackage ./julia-modules/indexing { inherit julia; };

languageServerName = "LanguageServer";

passthru = {
inherit languageServerName;
};

in

common.writeTextDirWithMeta julia.meta "lib/codedown/language-servers/julia-LanguageServerJl.yaml" (lib.generators.toYAML {} [{
name = "LanguageServer";
common.writeTextDirWithMetaAndPassthru julia.meta passthru "lib/codedown/language-servers/julia-LanguageServerJl.yaml" (lib.generators.toYAML {} [{
name = languageServerName;
display_name = "LanguageServer.jl";
description = "An implementation of the Microsoft Language Server Protocol for the Julia language";
icon = ./julia-logo-64x64.png;
4 changes: 3 additions & 1 deletion languages/python/default.nix
Original file line number Diff line number Diff line change
@@ -198,6 +198,7 @@ lib.listToAttrs (map (x:
allPackages = [ps.ipykernel ps.ipywidgets] ++ chosenPackages;
python = basePython.withPackages (_: allPackages);
pythonWithPackages = f: basePython.withPackages (_: allPackages ++ f ps);
languageServers = chooseLanguageServers settingsToUse pythonWithPackages x;

in symlinkJoin {
name = x;
@@ -211,7 +212,7 @@ lib.listToAttrs (map (x:
python
ps.ipython
]
++ (chooseLanguageServers settingsToUse pythonWithPackages x)
++ languageServers
;

passthru = {
@@ -223,6 +224,7 @@ lib.listToAttrs (map (x:
inherit attrs extensions;
code_mirror_mode = "python";
};
languageServerNames = map (x: x.languageServerName) languageServers;
};
}
) {};
Original file line number Diff line number Diff line change
@@ -14,11 +14,17 @@ let

python = pythonWithPackages (ps: [ps.flake8]);

languageServerName = "flake8";

passthru = {
inherit languageServerName;
};

in

common.writeTextDirWithMeta python.pkgs.flake8.meta "lib/codedown/language-servers/python-${kernelName}-flake8.yaml"
common.writeTextDirWithMetaAndPassthru python.pkgs.flake8.meta passthru "lib/codedown/language-servers/python-${kernelName}-flake8.yaml"
(lib.generators.toYAML {} [{
name = "flake8";
name = languageServerName;
version = python.pkgs.flake8.version;
display_name = "Flake8";
description = python.pkgs.flake8.meta.description;
Original file line number Diff line number Diff line change
@@ -13,10 +13,16 @@ let

jls = pythonEnv.pkgs.jedi-language-server;

languageServerName = "jedi";

passthru = {
inherit languageServerName;
};

in

common.writeTextDirWithMeta jls.meta "lib/codedown/language-servers/python-${kernelName}-jedi.yaml" (lib.generators.toYAML {} [{
name = "jedi";
common.writeTextDirWithMetaAndPassthru jls.meta passthru "lib/codedown/language-servers/python-${kernelName}-jedi.yaml" (lib.generators.toYAML {} [{
name = languageServerName;
version = jls.version;
display_name = "Jedi";
description = jls.meta.description;
Original file line number Diff line number Diff line change
@@ -64,11 +64,17 @@ let
dontFixup = true;
};

languageServerName = "python-language-server";

passthru = {
inherit languageServerName;
};

in

common.writeTextDirWithMeta python-language-server.meta "lib/codedown/language-servers/python-${kernelName}-microsoft.yaml"
common.writeTextDirWithMetaAndPassthru python-language-server.meta passthru "lib/codedown/language-servers/python-${kernelName}-microsoft.yaml"
(lib.generators.toYAML {} [{
name = "python-language-server";
name = languageServerName;
version = python-language-server.version;
display_name = "Python Language Server";
description = python-language-server.meta.description;
Original file line number Diff line number Diff line change
@@ -40,11 +40,17 @@ let
# # ignoreCollisions = python == pkgs.python27;
# };

languageServerName = "python-language-server";

passthru = {
inherit languageServerName;
};

in

common.writeTextDirWithMeta python.pkgs.python-language-server.meta "lib/codedown/language-servers/python-${kernelName}-palantir.yaml"
common.writeTextDirWithMetaAndPassthru python.pkgs.python-language-server.meta passthru "lib/codedown/language-servers/python-${kernelName}-palantir.yaml"
(lib.generators.toYAML {} [{
name = "python-language-server";
name = languageServerName;
version = python.pkgs.python-language-server.version;
display_name = "Python Language Server";
description = python.pkgs.python-language-server.meta.description;
Original file line number Diff line number Diff line change
@@ -15,11 +15,17 @@ let

python = pythonWithPackages (ps: [ps.pycodestyle]);

languageServerName = "pycodestyle";

passthru = {
inherit languageServerName;
};

in

common.writeTextDirWithMeta python.pkgs.pycodestyle.meta "lib/codedown/language-servers/python-${kernelName}-pycodestyle.yaml"
common.writeTextDirWithMetaAndPassthru python.pkgs.pycodestyle.meta passthru "lib/codedown/language-servers/python-${kernelName}-pycodestyle.yaml"
(lib.generators.toYAML {} [{
name = "pycodestyle";
name = languageServerName;
version = python.pkgs.pycodestyle.version;
display_name = "pycodestyle";
description = python.pkgs.pycodestyle.meta.description;
Original file line number Diff line number Diff line change
@@ -15,11 +15,17 @@ let

python = pythonWithPackages (ps: [ps.pylint]);

languageServerName = "pylint";

passthru = {
inherit languageServerName;
};

in

common.writeTextDirWithMeta python.pkgs.pylint.meta "lib/codedown/language-servers/python-${kernelName}-pylint.yaml"
common.writeTextDirWithMetaAndPassthru python.pkgs.pylint.meta passthru "lib/codedown/language-servers/python-${kernelName}-pylint.yaml"
(lib.generators.toYAML {} [{
name = "pylint";
name = languageServerName;
version = python.pkgs.pylint;
display_name = "Pylint";
description = python.pkgs.pylint.meta.description;
Original file line number Diff line number Diff line change
@@ -22,10 +22,16 @@ let
--set PYTHONPATH $pythonEnv/${pythonEnv.sitePackages}
'';

languageServerName = "pyright";

passthru = {
inherit languageServerName;
};

in

common.writeTextDirWithMeta pyright.meta "lib/codedown/language-servers/python-${kernelName}-pyright.yaml" (lib.generators.toYAML {} [{
name = "pyright";
common.writeTextDirWithMetaAndPassthru pyright.meta passthru "lib/codedown/language-servers/python-${kernelName}-pyright.yaml" (lib.generators.toYAML {} [{
name = languageServerName;
version = pyright.version;
display_name = "Pyright";
description = pyright.meta.description;
Original file line number Diff line number Diff line change
@@ -41,11 +41,17 @@ let
# # ignoreCollisions = python == pkgs.python27;
# };

languageServerName = "python-lsp-server";

passthru = {
inherit languageServerName;
};

in

common.writeTextDirWithMeta python.pkgs.python-lsp-server.meta "lib/codedown/language-servers/python-${kernelName}-pythonlsp.yaml"
common.writeTextDirWithMetaAndPassthru python.pkgs.python-lsp-server.meta passthru "lib/codedown/language-servers/python-${kernelName}-pythonlsp.yaml"
(lib.generators.toYAML {} [{
name = "python-lsp-server";
name = languageServerName;
version = python.pkgs.python-lsp-server.version;
display_name = "Python LSP Server";
description = python.pkgs.python-lsp-server.meta.description;
5 changes: 4 additions & 1 deletion languages/r/default.nix
Original file line number Diff line number Diff line change
@@ -75,6 +75,8 @@ listToAttrs [{
rWithPackages = rWrapper.override {
packages = basePackages;
};

languageServers = chooseLanguageServers settingsToUse rPackages rWrapper basePackages "R";
in
symlinkJoin {
name = "r";
@@ -86,7 +88,7 @@ listToAttrs [{
})
rWithPackages
]
++ (chooseLanguageServers settingsToUse rPackages rWrapper basePackages "R")
++ languageServers
;

passthru = {
@@ -98,6 +100,7 @@ listToAttrs [{
inherit attrs extensions;
code_mirror_mode = "r";
};
languageServerNames = map (x: x.languageServerName) languageServers;
};
}
) {};
10 changes: 8 additions & 2 deletions languages/r/language-server-languageserver/default.nix
Original file line number Diff line number Diff line change
@@ -17,10 +17,16 @@ let
packages = [languageserver] ++ languageserver.languageServerDeps ++ basePackages;
};

languageServerName = "languageserver";

passthru = {
inherit languageServerName;
};

in

common.writeTextDirWithMeta languageserver.meta "lib/codedown/language-servers/r-${kernelName}-languageserver.yaml" (lib.generators.toYAML {} [{
name = "languageserver";
common.writeTextDirWithMetaAndPassthru languageserver.meta passthru "lib/codedown/language-servers/r-${kernelName}-languageserver.yaml" (lib.generators.toYAML {} [{
name = languageServerName;
version = languageserver.version;
display_name = "";
description = "An implementation of the Language Server Protocol for R";
4 changes: 3 additions & 1 deletion languages/ruby/default.nix
Original file line number Diff line number Diff line change
@@ -88,6 +88,7 @@ listToAttrs (map (x:
}@args:
let
settingsToUse = (common.makeDefaultSettings settingsSchema) // settings;
languageServers = chooseLanguageServers settingsToUse packageOptions x;
in symlinkJoin {
name = x;
paths = [
@@ -97,7 +98,7 @@ listToAttrs (map (x:
})
ruby
]
++ (chooseLanguageServers settingsToUse packageOptions x)
++ languageServers
;
passthru = {
inherit meta packageOptions packageSearch versions;
@@ -107,6 +108,7 @@ listToAttrs (map (x:
inherit attrs extensions;
code_mirror_mode = "ruby";
};
languageServerNames = map (x: x.languageServerName) languageServers;
};
}
) {};
17 changes: 11 additions & 6 deletions languages/ruby/solargraph.nix
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
{ pkgs
{ callPackage
, lib

, rubyPackages
, solargraph ? rubyPackages.solargraph
, kernelName
}:

with pkgs;
with pkgs.lib;

let
common = callPackage ../common.nix {};

languageServerName = "solargraph";

passthru = {
inherit languageServerName;
};

in

common.writeTextDirWithMeta solargraph.meta "lib/codedown/language-servers/ruby-solargraph.yaml" (lib.generators.toYAML {} [{
name = "solargraph";
common.writeTextDirWithMetaAndPassthru solargraph.meta passthru "lib/codedown/language-servers/ruby-solargraph.yaml" (lib.generators.toYAML {} [{
name = languageServerName;
version = solargraph.version;
display_name = "Solargraph";
description = "A Ruby language server";
4 changes: 3 additions & 1 deletion languages/rust/default.nix
Original file line number Diff line number Diff line change
@@ -108,6 +108,7 @@ listToAttrs (map (x:
}).withPackages (map common.packageName packages);

settingsToUse = (common.makeDefaultSettings settingsSchema) // settings;
languageServers = chooseLanguageServers settingsToUse rust evcxr.cargoHome x;
in symlinkJoin {
name = "rust";

@@ -122,7 +123,7 @@ listToAttrs (map (x:
rustPackages.cargo
pkgs.gcc
]
++ (chooseLanguageServers settingsToUse rust evcxr.cargoHome x)
++ languageServers
;

passthru = {
@@ -134,6 +135,7 @@ listToAttrs (map (x:
inherit attrs extensions;
code_mirror_mode = "rust";
};
languageServerNames = map (x: x.languageServerName) languageServers;
};
}
) {};
16 changes: 12 additions & 4 deletions languages/rust/language_server_rust_analyzer/config.nix
Original file line number Diff line number Diff line change
@@ -26,8 +26,16 @@ let

shadowDirTemplate = cargoHome;

config = raw: {
name = "rust-analyzer${if raw then "-raw" else ""}";
raw = false;

languageServerName = "rust-analyzer${if raw then "-raw" else ""}";

passthru = {
inherit languageServerName;
};

config = {
name = languageServerName;
version = rustAnalyzerToUse.version;
display_name = "rust-analyzer";
description = rustAnalyzerToUse.meta.description;
@@ -169,6 +177,6 @@ let

in

common.writeTextDirWithMeta rust-analyzer.meta "lib/codedown/language-servers/rust-${kernelName}-rust-analyzer.yaml" (lib.generators.toYAML {} [
(config false)
common.writeTextDirWithMetaAndPassthru rust-analyzer.meta passthru "lib/codedown/language-servers/rust-${kernelName}-rust-analyzer.yaml" (lib.generators.toYAML {} [
config
])

0 comments on commit ae60440

Please sign in to comment.