Skip to content

Commit 796ace6

Browse files
committed
plugins/lsp: set a defaultText for cmd
1 parent 88652ce commit 796ace6

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

plugins/lsp/language-servers/_mk-lsp.nix

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
serverName ? name,
1111
package ? null,
1212
url ? null,
13-
cmd ? (cfg: null),
13+
cmd ? null,
14+
cmdText ? throw "cmdText is required when cmd is a function",
1415
settings ? (cfg: cfg),
1516
settingsOptions ? { },
1617
extraConfig ? cfg: { },
@@ -78,6 +79,25 @@ in
7879
cmd cfg
7980
else
8081
cmd;
82+
defaultText = lib.literalMD ''
83+
null when `package` is null, otherwise ${
84+
if args ? cmdText || builtins.isFunction cmd then
85+
let
86+
literal = lib.options.renderOptionValue cmdText;
87+
inherit (literal) text;
88+
in
89+
if literal._type == "literalMD" then
90+
text
91+
else if lib.hasInfix "\n" text || lib.hasInfix "``" text then
92+
"\n\n```\n${text}\n```"
93+
else
94+
"`` ${text} ``"
95+
else if cmd == null then
96+
"null"
97+
else
98+
"`[ ${lib.concatMapStringsSep " " builtins.toJSON cmd} ]`"
99+
}
100+
'';
81101
description = ''
82102
A list where each entry corresponds to the blankspace delimited part of the command that
83103
launches the server.

0 commit comments

Comments
 (0)