1
0
Fork 0
mirror of https://github.com/nix-community/nixvim.git synced 2025-11-09 03:56:05 +01:00

modules/lsp: propagate pkgs arg to server modules

This allows simplifying the `importApply` and also paves the way for
custom server modules to define arbitrary package options.
This commit is contained in:
Matt Sturgeon 2025-10-09 20:29:15 +01:00
parent 9e77c8e4a9
commit bb9d744b64
2 changed files with 7 additions and 6 deletions

View file

@ -12,10 +12,6 @@ let
cfg = config.lsp; cfg = config.lsp;
oldCfg = config.plugins.lsp; oldCfg = config.plugins.lsp;
# Import `server.nix` and apply args
# For convenience, we set a default here for args.pkgs
mkServerModule = args: lib.modules.importApply ./server.nix ({ inherit pkgs; } // args);
# Create a submodule type from `server.nix` # Create a submodule type from `server.nix`
# Used as the type for both the freeform `lsp.servers.<name>` # Used as the type for both the freeform `lsp.servers.<name>`
# and the explicitly declared `lsp.servers.*` options # and the explicitly declared `lsp.servers.*` options
@ -25,7 +21,12 @@ let
# Server modules have a `config` option, so we must use # Server modules have a `config` option, so we must use
# shorthandOnlyDefinesConfig to avoid confusing the module system. # shorthandOnlyDefinesConfig to avoid confusing the module system.
shorthandOnlyDefinesConfig = true; shorthandOnlyDefinesConfig = true;
modules = [ (mkServerModule args) ]; modules = [
(lib.modules.importApply ./server.nix args)
{
_module.args.pkgs = pkgs;
}
];
}; };
# Create a server option # Create a server option

View file

@ -3,12 +3,12 @@
name ? "the language server", name ? "the language server",
package ? null, package ? null,
config ? null, config ? null,
pkgs ? { },
}@args: }@args:
{ {
lib, lib,
name, name,
config, config,
pkgs,
... ...
}: }:
let let