diff options
| author | Elvis Claros Castro <elvis@claros.ar> | 2026-09-27 12:46:49 -0300 |
|---|---|---|
| committer | Elvis Claros Castro <elvis@claros.ar> | 2026-09-27 12:46:49 -0300 |
| commit | df7c711e2a49d51249350f52c63274b72aacb739 (patch) | |
| tree | 426da3b65371f857f3ee3d9893d7ff3279aac02e /lua/pi/snips/ft/go.lua | |
| parent | a0bd84df02ce235123dfc939327e8bd33dffdd7e (diff) | |
| download | nvim-conf-df7c711e2a49d51249350f52c63274b72aacb739.tar.gz nvim-conf-df7c711e2a49d51249350f52c63274b72aacb739.zip | |
Migración de plugins a funcionalidad nativa: statusline y treesitter propios, se quitan mason, lualine, mini, notify y otros
Diffstat (limited to 'lua/pi/snips/ft/go.lua')
| -rw-r--r-- | lua/pi/snips/ft/go.lua | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/lua/pi/snips/ft/go.lua b/lua/pi/snips/ft/go.lua index 9c3977f..4490e63 100644 --- a/lua/pi/snips/ft/go.lua +++ b/lua/pi/snips/ft/go.lua @@ -8,9 +8,6 @@ local i = ls.insert_node local rep = require("luasnip.extras").rep local fmt = require("luasnip.extras.fmt").fmt -local ts_locals = require "nvim-treesitter.locals" -local ts_utils = require "nvim-treesitter.ts_utils" - local get_node_text = vim.treesitter.get_node_text vim.treesitter.query.set( @@ -71,19 +68,28 @@ local handlers = { end, } +-- `nvim-treesitter.locals`/`ts_utils` no existen en la rama `main`; subimos a +-- mano por los padres del nodo bajo el cursor hasta la función que lo contiene. local function go_result_type(info) - local cursor_node = ts_utils.get_node_at_cursor() - local scope = ts_locals.get_scope_tree(cursor_node, 0) - local function_node - for _, v in ipairs(scope) do - if v:type() == "function_declaration" or v:type() == "method_declaration" or v:type() == "func_literal" then - function_node = v + local node = vim.treesitter.get_node() + while node do + local kind = node:type() + if kind == "function_declaration" or kind == "method_declaration" or kind == "func_literal" then + function_node = node break end + node = node:parent() + end + + if not function_node then + return end local query = vim.treesitter.query.get("go", "LuaSnip_Result") + if not query then + return + end for _, node in query:iter_captures(function_node, 0) do if handlers[node:type()] then return handlers[node:type()](node, info) |