From 3b79830ece04142a9f725049f4e98a879b40cf2c Mon Sep 17 00:00:00 2001 From: "Kenneth Benzie (Benie)" Date: Wed, 23 Jul 2025 14:39:58 +0100 Subject: [PATCH] Fix #include snippet for c/c++ --- snippets/c.lua | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) 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')), + }, {}), }