From 9eeaab25edd4d57e847317876b9d1e7f92ebbd20 Mon Sep 17 00:00:00 2001 From: Oleksandr Smirnov Date: Wed, 19 Mar 2025 00:16:22 +0200 Subject: [PATCH] fixup! fixup! refactor(_utils.ts): all public methods are just adapters --- lua/gopher/_utils/ts.lua | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/lua/gopher/_utils/ts.lua b/lua/gopher/_utils/ts.lua index 3bf190d..070e9e8 100644 --- a/lua/gopher/_utils/ts.lua +++ b/lua/gopher/_utils/ts.lua @@ -18,21 +18,15 @@ local queries = { ]], } ----@param parent_type string|[string] +---@param parent_type [string] ---@param node TSNode ---@return TSNode? local function get_parrent_node(parent_type, node) ---@type TSNode? local current = node while current do - if type(parent_type) == "string" then - if current:type() == parent_type then - break - end - elseif type(parent_type) == "table" then - if vim.tbl_contains(parent_type, current:type()) then - break - end + if vim.tbl_contains(parent_type, current:type()) then + break end current = current:parent() @@ -67,7 +61,7 @@ end ---@field end_line integer ---@param bufnr integer ----@param parent_type string|[string] +---@param parent_type [string] ---@param query string ---@return gopher.TsResult local function do_stuff(bufnr, parent_type, query) @@ -107,12 +101,12 @@ end ---@param bufnr integer function ts.get_package_under_cursor(bufnr) - return do_stuff(bufnr, "package_clause", queries.package) + return do_stuff(bufnr, { "package_clause" }, queries.package) end ---@param bufnr integer function ts.get_interface_under_cursor(bufnr) - return do_stuff(bufnr, "type_declaration", queries.interface) + return do_stuff(bufnr, { "type_declaration" }, queries.interface) end return ts