diff options
author | Thomas Voss <mail@thomasvoss.com> | 2023-11-20 23:49:51 +0100 |
---|---|---|
committer | Thomas Voss <mail@thomasvoss.com> | 2023-11-20 23:49:51 +0100 |
commit | 6ec3f9d0cd7e3fdb11c3946db04ef3ba7d6f7dfc (patch) | |
tree | 3e212f4592d3074326a3f221ab4f129e8a3865f2 /.config/nvim/after/plugin/luasnip.lua | |
parent | 776c6d5f0fc2436d41f27efb7f3422516fa04714 (diff) |
nvim: Add snippet for include guards
Diffstat (limited to '.config/nvim/after/plugin/luasnip.lua')
-rw-r--r-- | .config/nvim/after/plugin/luasnip.lua | 24 |
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() |