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": { "locked": {
"lastModified": 1716215872, "lastModified": 1716244689,
"narHash": "sha256-zjy9raJUx+14DVMDuVfZYbBOPcHgMBxk2vt+rmNn7uk=", "narHash": "sha256-tFsMxZcbg8WAmNmmL/WxFjp4wgCK2XzTDkM5PNZqCZQ=",
"ref": "refs/heads/main", "ref": "refs/heads/main",
"rev": "463a4f2d43033dc75d4e84522d0ff670001622bb", "rev": "881339ef7077b5c1d07041a0024575a4170c0174",
"revCount": 80, "revCount": 83,
"type": "git", "type": "git",
"url": "https://git.pleshevski.ru/pleshevskiy/nixeovim" "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 = [ plugins.snippet.luasnip.snippetGroups = [
{ {
filetype = "nix"; filetype = "nix";
snippets = { snippets = {
"if".nodes = [ "if".nodes = [
(t "if ") { text = "if "; }
(i 1 "condition") { jump = 1; text = "condition"; }
(t " then ") { text = " then "; }
(i 2 "trueBody") { jump = 2; text = "trueBody"; }
(t " else ") { text = " else "; }
(i 3 "falseBody") { jump = 3; text = "falseBody"; }
(t ";") { text = ";"; }
]; ];
"var".nodes = [ "var".nodes = [
(i 1 "name") { jump = 1; text = "name"; }
(t " = ") { text = " = "; }
(c 2 [
(i null "value")
{ {
snippet.nodes = [ jump = 2;
{ insert = 1; } choices = [
(t "[") { kind = "insert"; text = "value"; }
{ insert = 2; } {
(t "]") nodes = [
{ jump = 1; }
{ text = "["; }
{ jump = 2; }
{ text = "]"; }
]; ];
} }
{ {
snippet.nodes = [ nodes = [
{ insert = 1; } { jump = 1; }
(t "{") { text = "{"; }
{ insert = 2; } { jump = 2; }
(t "}") { text = "}"; }
]; ];
} }
]) ];
(t ";") }
{ 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 = [ "" "}" ]; }
]; ];
}; };
} }