feat(gotests): add generate one test
docs(gotests): add generate one test
This commit is contained in:
parent
507ccb6347
commit
8b3c68e38a
5 changed files with 74 additions and 2 deletions
|
|
@ -3,6 +3,8 @@ local M = {
|
|||
querys = {
|
||||
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]],
|
||||
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)]],
|
||||
},
|
||||
}
|
||||
|
||||
|
|
@ -31,4 +33,15 @@ function M.get_struct_node_at_pos(row, col, bufnr)
|
|||
end
|
||||
end
|
||||
|
||||
function M.get_func_method_node_at_pos(row, col, bufnr)
|
||||
local query = M.querys.func .. " " .. M.querys.method_name
|
||||
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
|
||||
print "func not found"
|
||||
else
|
||||
return ns[#ns]
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue