From 881339ef7077b5c1d07041a0024575a4170c0174 Mon Sep 17 00:00:00 2001 From: Dmitriy Pleshevskiy Date: Tue, 21 May 2024 01:38:09 +0300 Subject: [PATCH] modules/luasnip: add choices to avoid choice kind --- modules/plugins/snippet/luasnip.nix | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/modules/plugins/snippet/luasnip.nix b/modules/plugins/snippet/luasnip.nix index b8c6152..7ae96d6 100644 --- a/modules/plugins/snippet/luasnip.nix +++ b/modules/plugins/snippet/luasnip.nix @@ -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 ]