mirror of
https://github.com/nix-community/nixvim.git
synced 2025-11-09 03:56:05 +01:00
Merge e868bd6aa1 into 3031d4ab61
This commit is contained in:
commit
e7884fff5a
3 changed files with 62 additions and 18 deletions
38
modules/lsp/servers/custom/hls.nix
Normal file
38
modules/lsp/servers/custom/hls.nix
Normal 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
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -1,40 +1,44 @@
|
||||||
{
|
{
|
||||||
config,
|
|
||||||
lib,
|
lib,
|
||||||
pkgs,
|
pkgs,
|
||||||
|
config,
|
||||||
|
options,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
cfg = config.plugins.lsp.servers.hls;
|
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
|
in
|
||||||
{
|
{
|
||||||
options.plugins.lsp.servers.hls = {
|
options.plugins.lsp.servers.hls = {
|
||||||
installGhc = lib.mkOption {
|
installGhc = lib.mkOption {
|
||||||
type = with types; nullOr bool;
|
type = lib.types.nullOr lib.types.bool;
|
||||||
default = null;
|
default = null;
|
||||||
example = true;
|
example = true;
|
||||||
description = "Whether to install `ghc`.";
|
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 {
|
config = lib.mkIf enabled {
|
||||||
warnings = lib.nixvim.mkWarnings "plugins.lsp.servers.hls" {
|
lsp.servers.hls = {
|
||||||
when = cfg.installGhc == null;
|
installGhc = lib.mkIf useInstallGhcValue (
|
||||||
message = ''
|
lib.modules.mkAliasAndWrapDefsWithPriority lib.id opts.installGhc
|
||||||
`hls` relies on `ghc` (the Glasgow Haskell Compiler).
|
);
|
||||||
- Set `plugins.lsp.servers.hls.installGhc = true` to install it automatically with Nixvim.
|
ghcPackage = lib.mkIf (opts.ghcPackage.highestPrio < 1500) (
|
||||||
You can customize which package to install by changing `plugins.lsp.servers.hls.ghcPackage`.
|
lib.modules.mkAliasAndWrapDefsWithPriority lib.id opts.ghcPackage
|
||||||
- Set `plugins.lsp.servers.hls.installGhc = false` to not have it install through Nixvim.
|
);
|
||||||
By doing so, you will dismiss this warning.
|
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extraPackages = lib.optionals (!cfg.packageFallback) ghcPackage;
|
|
||||||
extraPackagesAfter = lib.optionals cfg.packageFallback ghcPackage;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -187,6 +187,7 @@
|
||||||
hls = {
|
hls = {
|
||||||
enable = true;
|
enable = true;
|
||||||
packageFallback = true;
|
packageFallback = true;
|
||||||
|
installGhc = true;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
@ -219,6 +220,7 @@
|
||||||
assertPrefix "nil" nil_ls.package
|
assertPrefix "nil" nil_ls.package
|
||||||
++ assertSuffix "rust-analyzer" rust_analyzer.package
|
++ assertSuffix "rust-analyzer" rust_analyzer.package
|
||||||
++ assertSuffix "haskell-language-server" hls.package
|
++ assertSuffix "haskell-language-server" hls.package
|
||||||
|
++ assertSuffix "ghc" hls.ghcPackage
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue