From 0a2432763235658445f096f7d879dde050696b0c Mon Sep 17 00:00:00 2001 From: Matt Sturgeon Date: Sun, 2 Jun 2024 18:58:06 +0100 Subject: [PATCH] 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. --- plugins/lsp/language-servers/_mk-lsp.nix | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/plugins/lsp/language-servers/_mk-lsp.nix b/plugins/lsp/language-servers/_mk-lsp.nix index 3869069f..615a35e7 100644 --- a/plugins/lsp/language-servers/_mk-lsp.nix +++ b/plugins/lsp/language-servers/_mk-lsp.nix @@ -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 + )); }