pull/180/head
ray-x 2 years ago
parent 5b70d93603
commit 3774ac0eba

@ -30,7 +30,6 @@ _GO_NVIM_CFG = {
-- when lsp_cfg is true
lsp_on_client_start = nil, -- it is a function with same signature as on_attach, will be called at end of
-- on_attach and allows you override some setup
lsp_format_on_save = 1,
lsp_document_formatting = true,
-- set to true: use gopls to format
-- false if you want to use other formatter tool(e.g. efm, nulls)

@ -176,7 +176,7 @@ function test_arg(arg)
}
local opts
local optarg
local optarg, unparsed
local optind
arg = arg or { "-t", "-r", "-c", "path1", "-g", "unit,integration", "path" }
-- arg = arg or { "-t", "-r", "-c", "-g", "unit,integration" }

@ -293,9 +293,9 @@ M.run = function(...)
if vim.fn.filereadable(covfn) == 0 then
vim.notify("no cov file specified or existed, will rerun coverage test", vim.lsp.log_levels.INFO)
else
local cov = M.read_cov(covfn)
vim.notify(string.format("total coverage: %d%%", cov.total_covered / cov.total_lines * 100))
return cov
local test_coverage = M.read_cov(covfn)
vim.notify(string.format("total coverage: %d%%", test_coverage.total_covered / test_coverage.total_lines * 100))
return test_coverage
end
end
if load == "-t" then

@ -163,7 +163,7 @@ M.goimport = function(...)
-- golines base formatter is goimports
local a = {}
if goimport == "golines" then
local a = vim.deepcopy(goimport_args)
a = vim.deepcopy(goimport_args)
end
run(a, buf, goimport)
end

@ -95,7 +95,7 @@ M.list_imports = function(path)
local resp = cmds.list_imports({
URI = path,
})
result = {}
local result = {}
for _, v in pairs(resp) do
if v.result then
for k, val in pairs(v.result) do

@ -54,7 +54,7 @@ local run = function(...)
utils.log(#arg, arg)
local recv = get_type_name()
local iface = get_interface_name()
iface = get_interface_name()
if #arg == 0 then
iface = vfn.input("Impl: generating method stubs for interface: ")
@ -82,7 +82,7 @@ local run = function(...)
if iface ~= nil then
-- " i.e: ':GoImpl s TypeName'
recv = select(1, ...)
recv_type = select(2, ...)
local recv_type = select(2, ...)
recv = string.lower(recv) .. " *" .. recv_type
else
recv_name = select(1, ...)

@ -41,7 +41,7 @@ local run = function(opts)
local optarg, _, reminder = getopt.get_opts(args, short_opts, long_opts)
local mockgen_cmd = { mockgen }
utils.log(arg)
utils.log(arg, reminder)
local sep = require("go.utils").sep()
@ -93,7 +93,7 @@ local run = function(opts)
utils.log(mockgen_cmd)
-- vim.cmd("normal! $%") -- do a bracket match. changed to treesitter
local opts = {
local mock_opts = {
on_exit = function(code, signal, data)
if code ~= 0 or signal ~= 0 then
-- there will be error popup from runner
@ -112,7 +112,7 @@ local run = function(opts)
end,
}
local runner = require("go.runner")
runner.run(mockgen_cmd, opts)
runner.run(mockgen_cmd, mock_opts)
return mockgen_cmd
end

@ -712,7 +712,7 @@ function util.run_command(cmd, ...)
return result
end
util.debounce = function(fn, duration)
util.debounce = function(func, duration)
local timer = vim.loop.new_timer()
local function inner(args)
timer:stop()
@ -720,7 +720,7 @@ util.debounce = function(fn, duration)
duration,
0,
vim.schedule_wrap(function()
fn(args)
func(args)
end)
)
end

@ -8,7 +8,7 @@ local aws = vim.split(
","
)
local function filter(prefix)
result = { ls.t("") }
local result = { ls.t("") }
print("filter", prefix)
if #prefix == 1 then
for _, v in pairs(aws) do
@ -87,8 +87,8 @@ ls.add_snippets("all", {
if not tonumber(lines) then
lines = 1
end
local l = vim.split(utils.lorem(), ", ")
return vim.list_slice(l, lines)
local lor = vim.split(utils.lorem(), ", ")
return vim.list_slice(lor, lines)
end)
),
})

@ -8,7 +8,7 @@ local cur_dir = vim.fn.expand("%:p:h")
describe("should run fillstruct", function()
vim.cmd([[packadd go.nvim]])
status = require("plenary.reload").reload_module("go.nvim")
require("plenary.reload").reload_module("go.nvim")
require("go").setup({ verbose = true })
-- _GO_NVIM_CFG.fillstruct = "fillstruct"
it("should run fillstruct", function()

@ -5,7 +5,7 @@ local busted = require("plenary/busted")
describe("should run gofmt", function()
-- vim.fn.readfile('minimal.vim')
-- vim.fn.writefile(vim.fn.readfile('fixtures/fmt/hello.go'), name)
status = require("plenary.reload").reload_module("go.nvim")
require("plenary.reload").reload_module("go.nvim")
it("should run fmt", function()
local name = vim.fn.tempname() .. ".go"
print("tmp:" .. name)
@ -33,7 +33,7 @@ describe("should run gofmt", function()
print("fmt" .. fmt)
vim.fn.assert_equal(fmt, expected)
eq(expected, fmt)
local cmd = "bd! " .. name
cmd = "bd! " .. name
vim.cmd(cmd)
end)
it("should run fmt sending from buffer", function()
@ -63,7 +63,7 @@ describe("should run gofmt", function()
print("fmt" .. fmt)
vim.fn.assert_equal(fmt, expected)
eq(expected, fmt)
local cmd = "bd! " .. name
cmd = "bd! " .. name
vim.cmd(cmd)
end)
it("should run import from file", function()

@ -15,7 +15,7 @@ describe("should run impl", function()
vim.cmd([[packadd go.nvim]])
vim.cmd([[packadd nvim-treesitter]])
status = require("plenary.reload").reload_module("go.nvim")
local status = require("plenary.reload").reload_module("go.nvim")
status = require("plenary.reload").reload_module("nvim-treesitter/nvim-treesitter")
require("go").setup({ verbose = true })

@ -5,7 +5,7 @@ local busted = require("plenary/busted")
describe("should run func make", function()
-- vim.fn.readfile('minimal.vim')
-- vim.fn.writefile(vim.fn.readfile('fixtures/fmt/hello.go'), name)
status = require("plenary.reload").reload_module("go.nvim")
require("plenary.reload").reload_module("go.nvim")
it("should make function", function()
--
-- go.nvim may not auto loaded

@ -8,6 +8,7 @@ local cur_dir = vim.fn.expand("%:p:h")
-- local ulog = require('go.utils').log
describe("should run gotags", function()
local cmd
-- vim.fn.readfile('minimal.vim')
-- vim.fn.writefile(vim.fn.readfile('fixtures/fmt/hello.go'), name)
-- status = require("plenary.reload").reload_module("go.nvim")
@ -20,7 +21,7 @@ describe("should run gotags", function()
local expected = vim.fn.join(vim.fn.readfile(cur_dir
.. "/lua/tests/fixtures/tags/add_all_golden.go"),
"\n")
local cmd = " silent exe 'e " .. name .. "'"
cmd = " silent exe 'e " .. name .. "'"
vim.cmd(cmd)
local bufn = vim.fn.bufnr("")
@ -42,7 +43,7 @@ describe("should run gotags", function()
-- ulog("tagged file: " .. fmt)
vim.fn.assert_equal(fmt, expected)
eq(expected, fmt)
local cmd = "bd! " .. name
cmd = "bd! " .. name
vim.cmd(cmd)
end)
it("should rm json tags", function()
@ -54,7 +55,7 @@ describe("should run gotags", function()
local expected = vim.fn.join(vim.fn.readfile(cur_dir
.. "/lua/tests/fixtures/tags/add_all_input.go"),
"\n")
local cmd = " silent exe 'e " .. name .. "'"
cmd = " silent exe 'e " .. name .. "'"
vim.cmd(cmd)
local bufn = vim.fn.bufnr("")
@ -82,7 +83,7 @@ describe("should run gotags", function()
-- ulog("tagged file: " .. fmt)
vim.fn.assert_equal(fmt, expected)
eq(expected, fmt)
local cmd = "bd! " .. name
cmd = "bd! " .. name
vim.cmd(cmd)
end)
it("should run clear json tags by default", function()
@ -94,7 +95,7 @@ describe("should run gotags", function()
local expected = vim.fn.join(vim.fn.readfile(cur_dir
.. "/lua/tests/fixtures/tags/add_all_input.go"),
"\n")
local cmd = " silent exe 'e " .. name .. "'"
cmd = " silent exe 'e " .. name .. "'"
vim.cmd(cmd)
local bufn = vim.fn.bufnr("")
@ -122,7 +123,7 @@ describe("should run gotags", function()
-- ulog("tagged file: " .. fmt)
vim.fn.assert_equal(fmt, expected)
eq(expected, fmt)
local cmd = "bd! " .. name
cmd = "bd! " .. name
vim.cmd(cmd)
end)
it("should clear all tags", function()
@ -135,7 +136,7 @@ describe("should run gotags", function()
local expected = vim.fn.join(vim.fn.readfile(cur_dir
.. "/lua/tests/fixtures/tags/add_all_input.go"),
"\n")
local cmd = " silent exe 'e " .. name .. "'"
cmd = " silent exe 'e " .. name .. "'"
vim.cmd(cmd)
local bufn = vim.fn.bufnr("")
@ -163,7 +164,7 @@ describe("should run gotags", function()
-- ulog("tagged file: " .. fmt)
vim.fn.assert_equal(fmt, expected)
eq(expected, fmt)
local cmd = "bd! " .. name
cmd = "bd! " .. name
vim.cmd(cmd)
end)
end)

@ -5,7 +5,7 @@ local busted = require("plenary/busted")
describe("should run func test", function()
-- vim.fn.readfile('minimal.vim')
-- vim.fn.writefile(vim.fn.readfile('fixtures/fmt/hello.go'), name)
status = require("plenary.reload").reload_module("go.nvim")
local status = require("plenary.reload").reload_module("go.nvim")
it("should test function", function()
--
-- go.nvim may not auto loaded

@ -12,7 +12,7 @@ local input = {
"}",
"type z struct{}",
}
local status
local default = {
["function"] = "func",
["method"] = "func",
@ -38,8 +38,9 @@ describe("should get nodes ", function()
vim.fn.append(0, input)
vim.cmd([[w]])
local bufn = vim.fn.bufnr("")
status = require("plenary.reload").reload_module("go.nvim")
status = require("plenary.reload").reload_module("nvim-treesitter/nvim-treesitter")
require("plenary.reload").reload_module("go.nvim")
require("plenary.reload").reload_module("nvim-treesitter/nvim-treesitter")
_GO_NVIM_CFG.verbose = true
local cur_dir = vim.fn.expand("%:p:h")
local nodes = require("go.ts.nodes")

@ -1 +1,8 @@
std="lua51+vim"
std="vim"
[rules]
global_usage = "allow"
multiple_statements = "allow"
incorrect_standard_library_use = "allow"
unused_variable = "allow"
deprecated = "allow"

@ -1,3 +1,4 @@
indent_type = "Spaces"
indent_width = 2
column_width = 120
quote_style = "AutoPreferSingle"

@ -1,57 +0,0 @@
[selene]
base = "lua51"
name = "vim"
[vim]
any = true
[_G]
property = true
writable = "new-fields"
[_GO_NVIM_CFG]
property = true
writable = "new-fields"
[debug]
property = true
[[describe.args]]
type = "string"
[[describe.args]]
type = "function"
[[it.args]]
type = "string"
[[it.args]]
type = "function"
[[before_each.args]]
type = "function"
[[after_each.args]]
type = "function"
[assert.is_not]
any = true
[[assert.equals.args]]
type = "any"
[[assert.equals.args]]
type = "any"
[[assert.equals.args]]
type = "any"
required = false
[[assert.same.args]]
type = "any"
[[assert.same.args]]
type = "any"
[[assert.truthy.args]]
type = "any"
[[assert.spy.args]]
type = "any"
[[assert.stub.args]]
type = "any"

@ -0,0 +1,65 @@
---
base: lua52
name: vim
globals:
ListView:
any: true
ListViewCtrl:
any: true
Panel:
any: true
TextView:
any: true
TextViewCtrl:
any: true
View:
any: true
ViewCtrl:
any: true
packer_plugins:
any: true
_G:
property: new-fields
_GO_NVIM_CFG:
property: new-fields
after_each:
args:
- type: function
assert.are.same:
any: true
assert.equals:
args:
- type: any
- type: any
- required: false
type: any
assert.is_not:
any: true
assert.same:
args:
- type: any
- type: any
assert.spy:
args:
- type: any
assert.stub:
args:
- type: any
assert.truthy:
args:
- type: any
before_each:
args:
- type: function
debug:
property: read-only
describe:
args:
- type: string
- type: function
it:
args:
- type: string
- type: function
vim:
any: true
Loading…
Cancel
Save