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