marleyvim/nvim/lua/snippets/nix.lua
punkfairie fbeb45e70b
feat: LuaSnip
Haven't figured out personal snippets yet.
2025-01-01 13:59:07 -08:00

148 lines
2.6 KiB
Lua

local ls = require("luasnip")
local s = ls.snippet
local i = ls.insert_node
local f = ls.function_node
local fmta = require("luasnip.extras.fmt").fmta
local rep = require("luasnip.extras").rep
local fill = require("snippets.helpers").fill
return {
s(
{ trig = "dc", desc = "divider comment" },
f(fill, {}, { user_args = { "#%- " } })
),
s(
{ trig = "mexpr", desc = "Basic module expression" },
fmta(
[[
{ <>... }:
{
<>
}
]],
{ i(1), i(0) }
)
),
s(
{ trig = "ovr", desc = "Override" },
fmta(
[[
<> = prev.<>.override {
<>
};
]],
{ i(1, "pkg"), rep(1), i(0) }
)
),
s(
{ trig = "ovra", desc = "OverrideAttrs" },
fmta(
[[
<> = prev.<>.overrideAttrs (old: {
<>
});
]],
{ i(1, "pkg"), rep(1), i(0) }
)
),
s(
{ trig = "hpkg", desc = "home.packages list" },
fmta(
[[
home.packages = with pkgs; [
<>
];<>
]],
{ i(1), i(0) }
)
),
s(
{ trig = "shm", desc = "Snowfall lib home module" },
fmta(
[[
{
lib,
config,<>
...
}:
let
inherit (lib) mkEnableOption mkIf;<>
cfg = config.marleyos.<>.<>;<>
in
{
options.marleyos.<>.<>.enable = mkEnableOption "<>";
config = mkIf cfg.enable {
<>
};
}
]],
{
i(1), -- extra args
i(2, { "", " inherit (lib.marleyos) enabled;" }),
i(3), -- group
i(4), -- mod
i(5, { "", " inherit (config.marleyos.theme) colors;" }),
rep(3), -- group
rep(4), -- mod
rep(4), -- mod
i(0), -- end
}
)
),
s(
{ trig = "ith", desc = "Inherit theme definition" },
fmta(
[[
inherit (config.marleyos.theme) colors;<>
]],
{ i(0) }
)
),
s(
{ trig = "erpth", desc = "Enable rose-pine theme module option" },
fmta(
[[
rose-pine = mkIf colors.isRosePine enabled;<>
]],
{ i(0) }
)
),
s(
{ trig = "sov", desc = "Snowfall lib overlay" },
fmta(
[[
<>: final: prev: {
<>
}
]],
{ i(1, "_"), i(0) }
)
),
s(
{ trig = "nvk", desc = "NixVim keymap attr set" },
fmta(
[[
{
mode = [ "<>"<> ];
key = "<>";
action = "<>";
options = {
desc = "<>";<>
};
}<>
]],
{ i(1), i(2), i(3), i(4), i(5), i(6), i(0) }
)
),
}