refactor: add comments & update type anotation

This commit is contained in:
Smirnov Olexander 2022-06-22 14:42:14 +03:00
parent c1de269ef4
commit 250d4de718
7 changed files with 14 additions and 6 deletions

View file

@ -18,9 +18,9 @@ local function get_name_defaults()
}
end
---@param row any
---@param col any
---@param bufnr any
---@param row string
---@param col string
---@param bufnr string
---@return table|nil
function M.get_struct_node_at_pos(row, col, bufnr)
local query = M.querys.struct_block .. " " .. M.querys.em_struct_block
@ -33,6 +33,10 @@ function M.get_struct_node_at_pos(row, col, bufnr)
end
end
---@param row string
---@param col string
---@param bufnr string
---@return table|nil
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()

View file

@ -1,5 +1,6 @@
local Job = require "plenary.job"
---run "go generate"
return function(...)
local args = { ... }
if #args == 1 and args[1] == "%" then

View file

@ -1,5 +1,6 @@
local Job = require "plenary.job"
---run "go get"
return function(...)
local args = { ... }
for i, arg in ipairs(args) do

View file

@ -1,5 +1,6 @@
local Job = require "plenary.job"
---run "go mod"
return function(...)
local args = { ... }
local cmd_args = vim.list_extend({ "mod" }, args)

View file

@ -45,6 +45,8 @@ function M.func_test(parallel)
add_test(cmd_args)
end
---generate unit tests for all functions in current file
---@param parallel boolean
function M.all_tests(parallel)
local cmd_args = { "-all" }
if parallel then

View file

@ -1,6 +1,7 @@
local Job = require "plenary.job"
local ts_utils = require "gopher._utils.ts"
---@return string
local function get_struct()
local ns = ts_utils.get_struct_node_at_pos(unpack(vim.api.nvim_win_get_cursor(0)))
if ns == nil then
@ -68,7 +69,4 @@ return function(...)
local pos = vim.fn.getcurpos()[2]
table.insert(res_data, 1, "")
vim.fn.append(pos, res_data)
-- table.insert(res_data, 1, "")
-- vim.fn.append(vim.fn.getcurpos()[2], res_data)
end

View file

@ -5,6 +5,7 @@ local urls = {
gotests = "github.com/cweill/gotests",
}
---@param pkg string
local function install(pkg)
local url = urls[pkg] .. "@latest"