mkLsp: remove with lib;

This commit is contained in:
Heitor Augusto 2024-12-17 15:48:55 -03:00 committed by nix-infra-bot
parent 5201bb2f6f
commit a74897d033

View file

@ -25,12 +25,13 @@
lib, lib,
... ...
}: }:
with lib;
let let
cfg = config.plugins.lsp.servers.${name}; cfg = config.plugins.lsp.servers.${name};
opts = options.plugins.lsp.servers.${name}; opts = options.plugins.lsp.servers.${name};
enabled = config.plugins.lsp.enable && cfg.enable; enabled = config.plugins.lsp.enable && cfg.enable;
inherit (lib) mkOption types;
in in
{ {
meta.nixvimInfo = { meta.nixvimInfo = {
@ -46,7 +47,7 @@ in
options = { options = {
plugins.lsp.servers.${name} = { plugins.lsp.servers.${name} = {
enable = mkEnableOption description; enable = lib.mkEnableOption description;
package = package =
if lib.isOption package then if lib.isOption package then
@ -132,7 +133,7 @@ in
} // extraOptions; } // extraOptions;
}; };
config = mkIf enabled { config = lib.mkIf enabled {
extraPackages = [ cfg.package ]; extraPackages = [ cfg.package ];
plugins.lsp.enabledServers = [ plugins.lsp.enabledServers = [
@ -144,7 +145,7 @@ in
on_attach = lib.nixvim.ifNonNull' cfg.onAttach ( on_attach = lib.nixvim.ifNonNull' cfg.onAttach (
lib.nixvim.mkRaw '' lib.nixvim.mkRaw ''
function(client, bufnr) function(client, bufnr)
${optionalString (!cfg.onAttach.override) config.plugins.lsp.onAttach} ${lib.optionalString (!cfg.onAttach.override) config.plugins.lsp.onAttach}
${cfg.onAttach.function} ${cfg.onAttach.function}
end end
'' ''
@ -168,10 +169,10 @@ in
"servers" "servers"
]; ];
basePluginPath = basePath ++ [ name ]; basePluginPath = basePath ++ [ name ];
basePluginPathString = concatStringsSep "." basePluginPath; basePluginPathString = builtins.concatStringsSep "." basePluginPath;
in in
[ [
(mkRemovedOptionModule ( (lib.mkRemovedOptionModule (
basePluginPath ++ [ "extraSettings" ] basePluginPath ++ [ "extraSettings" ]
) "You can use `${basePluginPathString}.extraOptions.settings` instead.") ) "You can use `${basePluginPathString}.extraOptions.settings` instead.")
] ]
@ -187,7 +188,7 @@ in
) )
# Add an alias (with warning) for the lspconfig server name, if different to `name`. # Add an alias (with warning) for the lspconfig server name, if different to `name`.
# Note: users may use lspconfig's docs to guess the `plugins.lsp.servers.*` name # Note: users may use lspconfig's docs to guess the `plugins.lsp.servers.*` name
++ (optional (name != serverName) ( ++ (lib.optional (name != serverName) (
mkRenamedOptionModule (basePath ++ [ serverName ]) basePluginPath lib.mkRenamedOptionModule (basePath ++ [ serverName ]) basePluginPath
)); ));
} }