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