plugins/lsp: automatically add serverName alias

A warning will be printed if the `serverName` alias is used, which may
help new users to figure out the correct `plugins.lsp.servers.*` name.
This commit is contained in:
Matt Sturgeon 2024-06-02 18:58:06 +01:00
parent 61fa26c9e9
commit 0a24327632
No known key found for this signature in database
GPG key ID: 4F91844CED1A8299

View file

@ -113,14 +113,15 @@ in
} }
]; ];
}; };
imports = imports =
let let
basePluginPath = [ basePath = [
"plugins" "plugins"
"lsp" "lsp"
"servers" "servers"
name
]; ];
basePluginPath = basePath ++ [ name ];
basePluginPathString = concatStringsSep "." basePluginPath; basePluginPathString = concatStringsSep "." basePluginPath;
in in
[ [
@ -128,5 +129,10 @@ in
basePluginPath ++ [ "extraSettings" ] basePluginPath ++ [ "extraSettings" ]
) "You can use `${basePluginPathString}.extraOptions.settings` instead.") ) "You can use `${basePluginPathString}.extraOptions.settings` instead.")
(extraConfig cfg) (extraConfig cfg)
]; ]
# 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
++ (optional (name != serverName) (
mkRenamedOptionModule (basePath ++ [ serverName ]) basePluginPath
));
} }