diff --git a/snippets/c.lua b/snippets/c.lua index a8d1e6a..f06b791 100644 --- a/snippets/c.lua +++ b/snippets/c.lua @@ -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')), + }, {}), }