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 end
---@param row any ---@param row string
---@param col any ---@param col string
---@param bufnr any ---@param bufnr string
---@return table|nil ---@return table|nil
function M.get_struct_node_at_pos(row, col, bufnr) function M.get_struct_node_at_pos(row, col, bufnr)
local query = M.querys.struct_block .. " " .. M.querys.em_struct_block 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
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) function M.get_func_method_node_at_pos(row, col, bufnr)
local query = M.querys.func .. " " .. M.querys.method_name local query = M.querys.func .. " " .. M.querys.method_name
local bufn = bufnr or vim.api.nvim_get_current_buf() local bufn = bufnr or vim.api.nvim_get_current_buf()

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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