mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-20 16:15:43 +02:00
plugins/lsp: add packageFallback option
Some checks are pending
Publish every Git push to main to FlakeHub / flakehub-publish (push) Waiting to run
Publish every git push to Flakestry / publish-flake (push) Waiting to run
Documentation / Build unstable (push) Waiting to run
Documentation / Build 24.11 (push) Waiting to run
Documentation / Build 25.05 (push) Waiting to run
Documentation / Combine builds (push) Blocked by required conditions
Documentation / Deploy (push) Blocked by required conditions
Some checks are pending
Publish every Git push to main to FlakeHub / flakehub-publish (push) Waiting to run
Publish every git push to Flakestry / publish-flake (push) Waiting to run
Documentation / Build unstable (push) Waiting to run
Documentation / Build 24.11 (push) Waiting to run
Documentation / Build 25.05 (push) Waiting to run
Documentation / Combine builds (push) Blocked by required conditions
Documentation / Deploy (push) Blocked by required conditions
https://github.com/nix-community/nixvim/pull/3445#pullrequestreview-2908615597
This commit is contained in:
parent
ee715541ab
commit
6a054de04d
4 changed files with 77 additions and 6 deletions
|
@ -55,6 +55,16 @@ in
|
||||||
lib.nixvim.mkMaybeUnpackagedOption "plugins.lsp.servers.${name}.package" pkgs name
|
lib.nixvim.mkMaybeUnpackagedOption "plugins.lsp.servers.${name}.package" pkgs name
|
||||||
package;
|
package;
|
||||||
|
|
||||||
|
packageFallback = mkOption {
|
||||||
|
type = types.bool;
|
||||||
|
default = false;
|
||||||
|
description = ''
|
||||||
|
When enabled, the language server package will be added to the end of the `PATH` _(suffix)_ instead of the beginning _(prefix)_.
|
||||||
|
|
||||||
|
This can be useful if you want local versions of the language server (e.g. from a devshell) to override the nixvim version.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
cmd = mkOption {
|
cmd = mkOption {
|
||||||
type = with types; nullOr (listOf str);
|
type = with types; nullOr (listOf str);
|
||||||
default =
|
default =
|
||||||
|
@ -148,7 +158,8 @@ in
|
||||||
};
|
};
|
||||||
|
|
||||||
config = lib.mkIf enabled {
|
config = lib.mkIf enabled {
|
||||||
extraPackages = [ cfg.package ];
|
extraPackages = lib.optional (!cfg.packageFallback) cfg.package;
|
||||||
|
extraPackagesAfter = lib.optional cfg.packageFallback cfg.package;
|
||||||
|
|
||||||
plugins.lsp.enabledServers = [
|
plugins.lsp.enabledServers = [
|
||||||
{
|
{
|
||||||
|
|
|
@ -7,6 +7,8 @@
|
||||||
let
|
let
|
||||||
cfg = config.plugins.lsp.servers.hls;
|
cfg = config.plugins.lsp.servers.hls;
|
||||||
inherit (lib) types;
|
inherit (lib) types;
|
||||||
|
|
||||||
|
ghcPackage = lib.optional (cfg.installGhc == true) cfg.ghcPackage;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options.plugins.lsp.servers.hls = {
|
options.plugins.lsp.servers.hls = {
|
||||||
|
@ -32,6 +34,7 @@ in
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
extraPackages = lib.optional (cfg.installGhc == true) cfg.ghcPackage;
|
extraPackages = lib.optionals (!cfg.packageFallback) ghcPackage;
|
||||||
|
extraPackagesAfter = lib.optionals cfg.packageFallback ghcPackage;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,11 @@ let
|
||||||
inherit (lib) mkPackageOption types;
|
inherit (lib) mkPackageOption types;
|
||||||
inherit (lib.nixvim) mkNullOrOption';
|
inherit (lib.nixvim) mkNullOrOption';
|
||||||
|
|
||||||
|
extraPackages =
|
||||||
|
lib.optional (cfg.installCargo == true) cfg.cargoPackage
|
||||||
|
++ lib.optional (cfg.installRustc == true) cfg.rustcPackage
|
||||||
|
++ lib.optional (cfg.installRustfmt == true) cfg.rustfmtPackage;
|
||||||
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options.plugins.lsp.servers.rust_analyzer = {
|
options.plugins.lsp.servers.rust_analyzer = {
|
||||||
|
@ -72,9 +77,7 @@ in
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
extraPackages =
|
extraPackages = lib.optionals (!cfg.packageFallback) extraPackages;
|
||||||
lib.optional (cfg.installCargo == true) cfg.cargoPackage
|
extraPackagesAfter = lib.optionals cfg.packageFallback extraPackages;
|
||||||
++ lib.optional (cfg.installRustc == true) cfg.rustcPackage
|
|
||||||
++ lib.optional (cfg.installRustfmt == true) cfg.rustfmtPackage;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -265,4 +265,58 @@
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
package-fallback =
|
||||||
|
{ config, ... }:
|
||||||
|
{
|
||||||
|
test.buildNixvim = false;
|
||||||
|
|
||||||
|
plugins.lsp = {
|
||||||
|
enable = true;
|
||||||
|
servers = {
|
||||||
|
nil_ls = {
|
||||||
|
enable = true;
|
||||||
|
|
||||||
|
packageFallback = true;
|
||||||
|
};
|
||||||
|
rust_analyzer = {
|
||||||
|
enable = true;
|
||||||
|
|
||||||
|
installCargo = true;
|
||||||
|
installRustc = true;
|
||||||
|
|
||||||
|
packageFallback = true;
|
||||||
|
};
|
||||||
|
hls = {
|
||||||
|
enable = true;
|
||||||
|
|
||||||
|
installGhc = true;
|
||||||
|
packageFallback = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
assertions =
|
||||||
|
let
|
||||||
|
assertAfter = name: pkg: [
|
||||||
|
{
|
||||||
|
assertion = lib.all (x: x != pkg) config.extraPackages;
|
||||||
|
message = "Expected `${name}` not to be in extraPackages";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
assertion = lib.any (x: x == pkg) config.extraPackagesAfter;
|
||||||
|
message = "Expected `${name}` to be in extraPackagesAfter";
|
||||||
|
}
|
||||||
|
];
|
||||||
|
in
|
||||||
|
with config.plugins.lsp.servers;
|
||||||
|
(
|
||||||
|
assertAfter "nil" nil_ls.package
|
||||||
|
++ assertAfter "rust-analyzer" rust_analyzer.package
|
||||||
|
++ assertAfter "cargo" rust_analyzer.cargoPackage
|
||||||
|
++ assertAfter "rustc" rust_analyzer.rustcPackage
|
||||||
|
++ assertAfter "haskell-language-server" hls.package
|
||||||
|
++ assertAfter "ghc" hls.ghcPackage
|
||||||
|
);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue