feat(_utils.ts): get interface
This commit is contained in:
parent
f9693c92ad
commit
7a2a46c06c
1 changed files with 16 additions and 0 deletions
|
|
@ -5,6 +5,7 @@ local M = {
|
||||||
struct_block = [[((type_declaration (type_spec name:(type_identifier) @struct.name type: (struct_type)))@struct.declaration)]],
|
struct_block = [[((type_declaration (type_spec name:(type_identifier) @struct.name type: (struct_type)))@struct.declaration)]],
|
||||||
em_struct_block = [[(field_declaration name:(field_identifier)@struct.name type: (struct_type)) @struct.declaration]],
|
em_struct_block = [[(field_declaration name:(field_identifier)@struct.name type: (struct_type)) @struct.declaration]],
|
||||||
package = [[(package_clause (package_identifier)@package.name)@package.clause]],
|
package = [[(package_clause (package_identifier)@package.name)@package.clause]],
|
||||||
|
interface = [[((type_declaration (type_spec name:(type_identifier) @interface.name type:(interface_type)))@interface.declaration)]],
|
||||||
method_name = [[((method_declaration receiver: (parameter_list)@method.receiver name: (field_identifier)@method.name body:(block))@method.declaration)]],
|
method_name = [[((method_declaration receiver: (parameter_list)@method.receiver name: (field_identifier)@method.name body:(block))@method.declaration)]],
|
||||||
func = [[((function_declaration name: (identifier)@function.name) @function.declaration)]],
|
func = [[((function_declaration name: (identifier)@function.name) @function.declaration)]],
|
||||||
},
|
},
|
||||||
|
|
@ -68,4 +69,19 @@ function M.get_package_node_at_pos(row, col, bufnr)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---@param row string
|
||||||
|
---@param col string
|
||||||
|
---@param bufnr string
|
||||||
|
---@return table|nil
|
||||||
|
function M.get_interface_node_at_pos(row, col, bufnr)
|
||||||
|
local query = M.querys.interface
|
||||||
|
local bufn = bufnr or vim.api.nvim_get_current_buf()
|
||||||
|
local ns = nodes.nodes_at_cursor(query, get_name_defaults(), bufn, row, col)
|
||||||
|
if ns == nil then
|
||||||
|
u.notify("interface not found", "warn")
|
||||||
|
else
|
||||||
|
return ns[#ns]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue