summaryrefslogtreecommitdiffstats
path: root/lua/snippets/c.lua
diff options
context:
space:
mode:
authorSquibid <me@zacharyscheiman.com>2025-01-24 13:56:11 -0600
committerSquibid <me@zacharyscheiman.com>2025-01-24 13:56:11 -0600
commit8eaa615596be321a3be12378c5e7d65cc7e482b6 (patch)
tree53fe601048ea302962420de4feff465e4c7d9317 /lua/snippets/c.lua
parenta0ebc39b59a98a69fbb6abf150f86dc4e19987a3 (diff)
downloadnvim-8eaa615596be321a3be12378c5e7d65cc7e482b6.tar.gz
nvim-8eaa615596be321a3be12378c5e7d65cc7e482b6.tar.bz2
nvim-8eaa615596be321a3be12378c5e7d65cc7e482b6.zip
kitchen sinkHEADmaster
Diffstat (limited to 'lua/snippets/c.lua')
-rw-r--r--lua/snippets/c.lua14
1 files changed, 14 insertions, 0 deletions
diff --git a/lua/snippets/c.lua b/lua/snippets/c.lua
index 65463dc..be0a683 100644
--- a/lua/snippets/c.lua
+++ b/lua/snippets/c.lua
@@ -9,8 +9,21 @@ local function c_func(func)
local q = vim.treesitter.query.parse("c", "(function_definition) @f")
local matches = q:iter_matches(tree, 0)
+ vim.treesitter.query.parse("c", "(identifier) @i")
+ local m = q:iter_matches(matches, 0)
+ print(vim.treesitter.get_node_text(m:child(), 0))
+
+ if true then
+ return
+ end
+
for _, match in matches do
for _, node in pairs(match) do
+ if not node or not node:child(1) or not node:child(1):child() then
+ -- print(vim.treesitter.get_node_text(node:child(1):child(), 0))
+ goto continue
+ end
+
if vim.treesitter.get_node_text(node:child(1):child(), 0) == func then
local def = ""
for i = 0, node:child_count() - 2 do
@@ -22,6 +35,7 @@ local function c_func(func)
-- Print the function name using node text
return def:gsub("\n", "")
end
+ ::continue::
end
end