neovim: refac luasnip snippets

This commit is contained in:
Dmitriy Pleshevskiy 2024-05-21 01:43:02 +03:00
parent e4b9b14c77
commit 2969485502
Signed by: pleshevskiy
GPG key ID: 17041163DA10A9A2
2 changed files with 83 additions and 38 deletions

View file

@ -279,11 +279,11 @@
]
},
"locked": {
"lastModified": 1716215872,
"narHash": "sha256-zjy9raJUx+14DVMDuVfZYbBOPcHgMBxk2vt+rmNn7uk=",
"lastModified": 1716244689,
"narHash": "sha256-tFsMxZcbg8WAmNmmL/WxFjp4wgCK2XzTDkM5PNZqCZQ=",
"ref": "refs/heads/main",
"rev": "463a4f2d43033dc75d4e84522d0ff670001622bb",
"revCount": 80,
"rev": "881339ef7077b5c1d07041a0024575a4170c0174",
"revCount": 83,
"type": "git",
"url": "https://git.pleshevski.ru/pleshevskiy/nixeovim"
},

View file

@ -1,47 +1,92 @@
{ ... }:
let
t = text: { inherit text; };
i = jump: text: { inherit jump text; };
c = jump: nodes: { inherit jump nodes; };
in
{
plugins.snippet.luasnip.snippetGroups = [
{
filetype = "nix";
snippets = {
"if".nodes = [
(t "if ")
(i 1 "condition")
(t " then ")
(i 2 "trueBody")
(t " else ")
(i 3 "falseBody")
(t ";")
{ text = "if "; }
{ jump = 1; text = "condition"; }
{ text = " then "; }
{ jump = 2; text = "trueBody"; }
{ text = " else "; }
{ jump = 3; text = "falseBody"; }
{ text = ";"; }
];
"var".nodes = [
(i 1 "name")
(t " = ")
(c 2 [
(i null "value")
{
snippet.nodes = [
{ insert = 1; }
(t "[")
{ insert = 2; }
(t "]")
];
}
{
snippet.nodes = [
{ insert = 1; }
(t "{")
{ insert = 2; }
(t "}")
];
}
])
(t ";")
{ jump = 1; text = "name"; }
{ text = " = "; }
{
jump = 2;
choices = [
{ kind = "insert"; text = "value"; }
{
nodes = [
{ jump = 1; }
{ text = "["; }
{ jump = 2; }
{ text = "]"; }
];
}
{
nodes = [
{ jump = 1; }
{ text = "{"; }
{ jump = 2; }
{ text = "}"; }
];
}
];
}
{ text = ";"; }
];
"module".nodes = [
{ text = "{ "; }
{
jump = 1;
choices = [
{ kind = "insert"; text = "pkgs, "; }
{ text = "config, "; }
{ text = "config, lib, "; }
{ text = "config, lib, pkgs, "; }
];
}
{ text = "..."; }
{ text = [ " }:" "" ]; }
{
jump = 2;
choices = [
{
nodes = [
{ jump = 1; }
{ text = "let "; }
{ jump = 2; }
{ text = "in"; }
];
}
{
nodes = [
{ jump = 1; }
{ text = "with "; }
{ jump = 2; text = "lib"; }
{ text = ";"; }
];
}
{ text = ""; }
];
}
{ text = [ "" "{" "" ]; }
{
jump = 3;
nodes = [
{ text = " "; }
{ jump = 1; text = "hello"; }
];
}
{ text = [ "" "}" ]; }
];
};
}