From 53fa869a7ea29d06ed64f74850f5cefdb8850884 Mon Sep 17 00:00:00 2001
From: Squibid <me@zacharyscheiman.com>
Date: Sun, 22 Dec 2024 14:01:57 -0500
Subject: update snippets

---
 lua/snippets/c.lua | 13 ++-----------
 1 file changed, 2 insertions(+), 11 deletions(-)

(limited to 'lua/snippets/c.lua')

diff --git a/lua/snippets/c.lua b/lua/snippets/c.lua
index 2d71253..65463dc 100644
--- a/lua/snippets/c.lua
+++ b/lua/snippets/c.lua
@@ -6,21 +6,12 @@ require('core.snippets.shorthands')
 local function c_func(func)
   local tree = vim.treesitter.get_parser():parse()[1]:root()
 
-  local q = vim.treesitter.query.parse("c", [[
-  (function_definition
-    declarator: (function_declarator
-      (identifier) @function_name
-    )
-  )
-  ]])
+  local q = vim.treesitter.query.parse("c", "(function_definition) @f")
   local matches = q:iter_matches(tree, 0)
 
   for _, match in matches do
     for _, node in pairs(match) do
-      if vim.treesitter.get_node_text(node, 0) == func then
-        while node:type() ~= "function_definition" do
-          node = node:parent()
-        end
+      if vim.treesitter.get_node_text(node:child(1):child(), 0) == func then
         local def = ""
         for i = 0, node:child_count() - 2 do
           def = def..vim.treesitter.get_node_text(node:child(i), 0)
-- 
cgit v1.2.1