summaryrefslogtreecommitdiff
path: root/.config/nvim/after/plugin
diff options
context:
space:
mode:
Diffstat (limited to '.config/nvim/after/plugin')
-rw-r--r--.config/nvim/after/plugin/luasnip.lua24
1 files changed, 24 insertions, 0 deletions
diff --git a/.config/nvim/after/plugin/luasnip.lua b/.config/nvim/after/plugin/luasnip.lua
index 6d9d662..6bd0f26 100644
--- a/.config/nvim/after/plugin/luasnip.lua
+++ b/.config/nvim/after/plugin/luasnip.lua
@@ -11,6 +11,12 @@ local sn = ls.snippet_node
local t = ls.text_node
local fmt = require('luasnip.extras.fmt').fmt
+local function same(index)
+ return f(function(args)
+ return args[1]
+ end, { index })
+end
+
ls.config.set_config {
history = true,
updateevents = 'TextChanged,TextChangedI',
@@ -181,6 +187,24 @@ ls.add_snippets('go', {
),
})
+
+ls.add_snippets('c', {
+ s(
+ 'gu',
+ fmt(
+ [[
+ #ifndef {}_H
+ #define {}_H
+
+ {}
+
+ #endif /* !{}_H */
+ ]],
+ { i(1), same(1), i(0), same(1), }
+ )
+ ),
+})
+
vim.keymap.set({ 'i', 's' }, '<C-l>', function()
if ls.expand_or_jumpable() then
ls.expand_or_jump()