mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-21 00:25:42 +02:00
plugins/lsp: modernize implem of language-servers
This commit is contained in:
parent
57464f22bb
commit
e6018ac195
12 changed files with 618 additions and 598 deletions
|
@ -4,26 +4,26 @@
|
|||
pkgs,
|
||||
...
|
||||
}:
|
||||
with lib;
|
||||
let
|
||||
cfg = config.plugins.lsp.servers.rust_analyzer;
|
||||
inherit (lib) mkPackageOption types;
|
||||
inherit (lib.nixvim) mkNullOrOption';
|
||||
|
||||
in
|
||||
{
|
||||
options.plugins.lsp.servers.rust_analyzer = {
|
||||
# https://github.com/nix-community/nixvim/issues/674
|
||||
installCargo = mkOption {
|
||||
type = with types; nullOr bool;
|
||||
default = null;
|
||||
installCargo = mkNullOrOption' {
|
||||
type = types.bool;
|
||||
example = true;
|
||||
description = "Whether to install `cargo`.";
|
||||
};
|
||||
|
||||
# TODO: make nullable?
|
||||
cargoPackage = mkPackageOption pkgs "cargo" { };
|
||||
cargoPackage = lib.mkPackageOption pkgs "cargo" { };
|
||||
|
||||
installRustc = mkOption {
|
||||
type = with types; nullOr bool;
|
||||
default = null;
|
||||
installRustc = mkNullOrOption' {
|
||||
type = types.bool;
|
||||
example = true;
|
||||
description = "Whether to install `rustc`.";
|
||||
};
|
||||
|
@ -31,9 +31,8 @@ in
|
|||
# TODO: make nullable
|
||||
rustcPackage = mkPackageOption pkgs "rustc" { };
|
||||
|
||||
installRustfmt = mkOption {
|
||||
type = with types; nullOr bool;
|
||||
default = null;
|
||||
installRustfmt = mkNullOrOption' {
|
||||
type = types.bool;
|
||||
example = true;
|
||||
description = "Whether to install `rustfmt`.";
|
||||
};
|
||||
|
@ -41,9 +40,9 @@ in
|
|||
# TODO: make nullable
|
||||
rustfmtPackage = mkPackageOption pkgs "rustfmt" { };
|
||||
};
|
||||
config = mkIf cfg.enable {
|
||||
config = lib.mkIf cfg.enable {
|
||||
warnings =
|
||||
(optional (cfg.installCargo == null) ''
|
||||
(lib.optional (cfg.installCargo == null) ''
|
||||
`rust_analyzer` relies on `cargo`.
|
||||
- Set `plugins.lsp.servers.rust_analyzer.installCargo = true` to install it automatically
|
||||
with Nixvim.
|
||||
|
@ -53,7 +52,7 @@ in
|
|||
through Nixvim.
|
||||
By doing so, you will dismiss this warning.
|
||||
'')
|
||||
++ (optional (cfg.installRustc == null) ''
|
||||
++ (lib.optional (cfg.installRustc == null) ''
|
||||
`rust_analyzer` relies on `rustc`.
|
||||
- Set `plugins.lsp.servers.rust_analyzer.installRustc = true` to install it automatically
|
||||
with Nixvim.
|
||||
|
@ -65,9 +64,11 @@ in
|
|||
'');
|
||||
|
||||
extraPackages =
|
||||
with pkgs;
|
||||
optional (isBool cfg.installCargo && cfg.installCargo) cfg.cargoPackage
|
||||
++ optional (isBool cfg.installRustc && cfg.installRustc) cfg.rustcPackage
|
||||
++ optional (isBool cfg.installRustfmt && cfg.installRustfmt) cfg.rustfmtPackage;
|
||||
let
|
||||
isEnabled = x: lib.isBool x && x;
|
||||
in
|
||||
lib.optional (isEnabled cfg.installCargo) cfg.cargoPackage
|
||||
++ lib.optional (isEnabled cfg.installRustc) cfg.rustcPackage
|
||||
++ lib.optional (isEnabled cfg.installRustfmt) cfg.rustfmtPackage;
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue