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