modules/luasnip: add choices to avoid choice kind

This commit is contained in:
Dmitriy Pleshevskiy 2024-05-21 01:38:09 +03:00
parent aeb09834d6
commit 881339ef70
Signed by: pleshevskiy
GPG Key ID: 17041163DA10A9A2

View File

@ -39,6 +39,7 @@ let
}; };
inherit nodes; inherit nodes;
choices = nodes;
# only for kind=snippet # only for kind=snippet
indentString = mkOption { indentString = mkOption {
@ -51,13 +52,14 @@ let
config = config =
let let
inherit (config) kind text jump nodes; inherit (config) kind text jump nodes choices;
unwrapJump = index: if index == null then LuaNil else index; unwrapJump = index: if index == null then LuaNil else index;
in in
{ {
kind = lib.mkDefault ( kind = lib.mkDefault (
if nodes != [ ] then "snippet" if choices != [ ] then "choice"
else if nodes != [ ] then "snippet"
else if jump != null then "insert" else if jump != null then "insert"
else "text" else "text"
); );
@ -67,7 +69,7 @@ let
if text != null then call1 "t" text if text != null then call1 "t" text
else throw "luasnip textnode require a 'text' config" else throw "luasnip textnode require a 'text' config"
else if kind == "insert" then call "i" [ (unwrapJump jump) text ] else if kind == "insert" then call "i" [ (unwrapJump jump) text ]
else if kind == "choice" then call "c" [ (unwrapJump jump) (unwrapNodes nodes) ] else if kind == "choice" then call "c" [ (unwrapJump jump) (unwrapNodes choices) ]
else if kind == "snippet" then else if kind == "snippet" then
if config.indentString != "" then if config.indentString != "" then
call "isn" [ (unwrapJump jump) (unwrapNodes nodes) config.indentString ] call "isn" [ (unwrapJump jump) (unwrapNodes nodes) config.indentString ]