Fix #include snippet for c/c++

This commit is contained in:
Kenneth Benzie 2025-07-23 14:39:58 +01:00
parent fad688fc15
commit 3b79830ece

View File

@ -6,6 +6,7 @@ local text = luasnip.text_node
local insert = luasnip.insert_node local insert = luasnip.insert_node
local func = luasnip.function_node local func = luasnip.function_node
local choice = luasnip.choice_node local choice = luasnip.choice_node
local dynamic = luasnip.dynamic_node
local restore = luasnip.restore_node local restore = luasnip.restore_node
local snip = luasnip.snippet_node local snip = luasnip.snippet_node
local key = require("luasnip.nodes.key_indexer").new_key local key = require("luasnip.nodes.key_indexer").new_key
@ -27,23 +28,22 @@ local snippets = {
snippet('once', { snippet('once', {
text('#ifndef '), text('#ifndef '),
func(function(args) func(function(opts)
return args[1][1] return opts[1][1]
end, key('name')), end, key('guard')),
text({ '', '#define ' }), text({ '', '#define ' }),
insert(1, getIncludeGuardName(), { key = 'name' }), dynamic(1, function()
-- FIXME: dynamic(1, function(_, _) return snip(nil, {
-- return snip(nil, { insert(1, getIncludeGuardName(), { key = 'guard' }),
-- insert(1, getIncludeGuardName()) })
-- }) end),
-- end, { key = "name" }),
text({ '', '', '', }), text({ '', '', '', }),
insert(0, ''), insert(0, ''),
text({ '', '', '#endif // ' }), text({ '', '', '#endif // ' }),
func(function(args) func(function(opts)
return args[1][1] return opts[1][1]
end, key('name')), end, key('guard')),
}), }, {}),
} }