system/neovim/snippets.nix

50 lines
985 B
Nix
Raw Normal View History

2024-05-20 23:03:25 +03:00
{ ... }:
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 ";")
];
"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 ";")
];
};
}
];
}