1
0
Fork 0
mirror of https://github.com/nix-community/nixvim.git synced 2025-11-08 19:46:06 +01:00
This commit is contained in:
Matt Sturgeon 2025-11-08 00:10:25 +00:00 committed by GitHub
commit e7884fff5a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 62 additions and 18 deletions

View file

@ -0,0 +1,38 @@
{
lib,
pkgs,
config,
options,
...
}:
{
options = {
installGhc = lib.mkOption {
type = lib.types.bool;
default = false;
example = true;
description = "Whether to install `ghc`.";
};
ghcPackage = lib.mkPackageOption pkgs "ghc" { };
};
config = lib.mkIf config.enable {
warnings = lib.nixvim.mkWarnings "lsp.servers.hls" {
when = options.installGhc.highestPrio == 1500;
message = ''
`hls` relies on `ghc` (the Glasgow Haskell Compiler).
- Set `${options.installGhc} = true` to install it automatically with Nixvim.
You can customize which package to install by changing `${options.ghcPackage}`.
- Set `${options.installGhc} = false` to not have it install through Nixvim.
By doing so, you will dismiss this warning.
'';
};
packages = lib.mkIf config.installGhc {
${if config.packageFallback then "suffix" else "prefix"} = [
config.ghcPackage
];
};
};
}

View file

@ -1,40 +1,44 @@
{
config,
lib,
pkgs,
config,
options,
...
}:
let
cfg = config.plugins.lsp.servers.hls;
inherit (lib) types;
opts = options.plugins.lsp.servers.hls;
enabled = config.plugins.lsp.enable && cfg.enable;
ghcPackage = lib.optional (cfg.installGhc == true) cfg.ghcPackage;
# The new `installGhc` option doesn't support null values, so check how the old value is defined
installGhcValue =
lib.modules.mergeDefinitions opts.installGhc.loc opts.installGhc.type
opts.installGhc.definitionsWithLocations;
useInstallGhcValue = installGhcValue.optionalValue.value or null != null;
in
{
options.plugins.lsp.servers.hls = {
installGhc = lib.mkOption {
type = with types; nullOr bool;
type = lib.types.nullOr lib.types.bool;
default = null;
example = true;
description = "Whether to install `ghc`.";
apply = v: if enabled then config.lsp.servers.hls.installGhc else v;
};
ghcPackage = lib.mkPackageOption pkgs "ghc" { };
ghcPackage = lib.mkPackageOption pkgs "ghc" { } // {
apply = v: if enabled then config.lsp.servers.hls.ghcPackage else v;
};
};
config = lib.mkIf cfg.enable {
warnings = lib.nixvim.mkWarnings "plugins.lsp.servers.hls" {
when = cfg.installGhc == null;
message = ''
`hls` relies on `ghc` (the Glasgow Haskell Compiler).
- Set `plugins.lsp.servers.hls.installGhc = true` to install it automatically with Nixvim.
You can customize which package to install by changing `plugins.lsp.servers.hls.ghcPackage`.
- Set `plugins.lsp.servers.hls.installGhc = false` to not have it install through Nixvim.
By doing so, you will dismiss this warning.
'';
config = lib.mkIf enabled {
lsp.servers.hls = {
installGhc = lib.mkIf useInstallGhcValue (
lib.modules.mkAliasAndWrapDefsWithPriority lib.id opts.installGhc
);
ghcPackage = lib.mkIf (opts.ghcPackage.highestPrio < 1500) (
lib.modules.mkAliasAndWrapDefsWithPriority lib.id opts.ghcPackage
);
};
extraPackages = lib.optionals (!cfg.packageFallback) ghcPackage;
extraPackagesAfter = lib.optionals cfg.packageFallback ghcPackage;
};
}

View file

@ -187,6 +187,7 @@
hls = {
enable = true;
packageFallback = true;
installGhc = true;
};
};
};
@ -219,6 +220,7 @@
assertPrefix "nil" nil_ls.package
++ assertSuffix "rust-analyzer" rust_analyzer.package
++ assertSuffix "haskell-language-server" hls.package
++ assertSuffix "ghc" hls.ghcPackage
);
};