neovim: add some nix snippets

This commit is contained in:
Dmitriy Pleshevskiy 2024-05-20 23:03:25 +03:00
parent a4d425a8c9
commit f1f8b4f01e
Signed by: pleshevskiy
GPG key ID: 17041163DA10A9A2
3 changed files with 58 additions and 8 deletions

View file

@ -255,11 +255,11 @@
}, },
"nix2lua": { "nix2lua": {
"locked": { "locked": {
"lastModified": 1715344083, "lastModified": 1716215210,
"narHash": "sha256-7UehRa7etk0oqSH4ty0nUsmeO3Z+Y1dbKwrGSlgaMIc=", "narHash": "sha256-GjwpjhNGdrGH0dElAvcKSFY3nbRw4JYOKtKMmhMsEWw=",
"ref": "refs/heads/main", "ref": "refs/heads/main",
"rev": "6a096bf9a22903c92f0065ba3316d3821ddd8b72", "rev": "4d3ae67617c2c1301a1a90601e20e15614d20319",
"revCount": 41, "revCount": 52,
"type": "git", "type": "git",
"url": "https://git.pleshevski.ru/mynix/nix2lua" "url": "https://git.pleshevski.ru/mynix/nix2lua"
}, },
@ -279,11 +279,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1715970214, "lastModified": 1716215872,
"narHash": "sha256-x9bHVtPmk5BfGmVLfUhFcpVJdQZ5SstBRFy19WBp/W0=", "narHash": "sha256-zjy9raJUx+14DVMDuVfZYbBOPcHgMBxk2vt+rmNn7uk=",
"ref": "refs/heads/main", "ref": "refs/heads/main",
"rev": "51fcb9d9e41d9ac540a9840081fdce328e2117e0", "rev": "463a4f2d43033dc75d4e84522d0ff670001622bb",
"revCount": 73, "revCount": 80,
"type": "git", "type": "git",
"url": "https://git.pleshevski.ru/pleshevskiy/nixeovim" "url": "https://git.pleshevski.ru/pleshevskiy/nixeovim"
}, },

View file

@ -18,6 +18,7 @@ in
{ {
imports = [ imports = [
"${modulesPath}/profiles/recommended.nix" "${modulesPath}/profiles/recommended.nix"
./snippets.nix
]; ];
vim.opt = { vim.opt = {

49
neovim/snippets.nix Normal file
View file

@ -0,0 +1,49 @@
{ ... }:
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 ";")
];
};
}
];
}