plugins/lsp/hls: handle automatic installation of required GHC

This commit is contained in:
Gaetan Lepage 2024-10-13 15:22:01 +02:00 committed by nix-infra-bot
parent 767eb62f48
commit 619e24366e
3 changed files with 43 additions and 3 deletions

View file

@ -220,6 +220,7 @@ in
++ [ ++ [
./ccls.nix ./ccls.nix
./efmls-configs.nix ./efmls-configs.nix
./hls.nix
./pylsp.nix ./pylsp.nix
./rust-analyzer.nix ./rust-analyzer.nix
./svelte.nix ./svelte.nix

View file

@ -0,0 +1,34 @@
{
config,
lib,
pkgs,
...
}:
with lib;
let
cfg = config.plugins.lsp.servers.hls;
in
{
options.plugins.lsp.servers.hls = {
installGhc = mkOption {
type = with types; nullOr bool;
default = null;
example = true;
description = "Whether to install `ghc`.";
};
ghcPackage = mkPackageOption pkgs "ghc" { };
};
config = mkIf cfg.enable {
warnings = optional (cfg.installGhc == null) ''
`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.
'';
extraPackages = with pkgs; (optional ((isBool cfg.installGhc) && cfg.installGhc) cfg.ghcPackage);
};
}

View file

@ -16,12 +16,17 @@ let
plugins.lsp = { plugins.lsp = {
enable = true; enable = true;
servers.rust_analyzer = { servers = {
hls = {
installGhc = true;
};
rust_analyzer = {
installCargo = true; installCargo = true;
installRustc = true; installRustc = true;
}; };
}; };
}; };
};
enable-servers-module = enable-servers-module =
{ {