refactor(tests): use auto commands instead of putting it in each test
This commit is contained in:
parent
9d734f114d
commit
c0297ac1d6
3 changed files with 9 additions and 5 deletions
|
|
@ -52,3 +52,12 @@ if #vim.api.nvim_list_uis() == 0 then
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- needed for tests, i dont know the reason why, but on start
|
||||||
|
-- vim is not able to use treesitter for go by default
|
||||||
|
vim.api.nvim_create_autocmd("FileType", {
|
||||||
|
pattern = "go",
|
||||||
|
callback = function(args)
|
||||||
|
vim.treesitter.start(args.buf, "go")
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
|
||||||
|
|
@ -44,16 +44,12 @@ T["struct_tags"]["should add more than one tag"] = function()
|
||||||
|
|
||||||
--- with comma, like gomodifytags
|
--- with comma, like gomodifytags
|
||||||
child.cmd("silent edit " .. tmp)
|
child.cmd("silent edit " .. tmp)
|
||||||
child.lua "vim.treesitter.start()"
|
|
||||||
|
|
||||||
child.fn.setpos(".", { child.fn.bufnr(tmp), 3, 1 })
|
child.fn.setpos(".", { child.fn.bufnr(tmp), 3, 1 })
|
||||||
child.cmd "GoTagAdd test4,test5"
|
child.cmd "GoTagAdd test4,test5"
|
||||||
child.cmd "write"
|
child.cmd "write"
|
||||||
|
|
||||||
-- without comma
|
-- without comma
|
||||||
child.cmd("silent edit " .. tmp)
|
child.cmd("silent edit " .. tmp)
|
||||||
child.lua "vim.treesitter.start()"
|
|
||||||
|
|
||||||
child.fn.setpos(".", { child.fn.bufnr(tmp), 3, 1 })
|
child.fn.setpos(".", { child.fn.bufnr(tmp), 3, 1 })
|
||||||
child.cmd "GoTagAdd test1 test2"
|
child.cmd "GoTagAdd test1 test2"
|
||||||
child.cmd "write"
|
child.cmd "write"
|
||||||
|
|
|
||||||
|
|
@ -81,7 +81,6 @@ function testutils.setup_test(fixture, child, pos)
|
||||||
|
|
||||||
testutils.writefile(tmp, fixtures.input)
|
testutils.writefile(tmp, fixtures.input)
|
||||||
child.cmd("silent edit " .. tmp)
|
child.cmd("silent edit " .. tmp)
|
||||||
child.lua "vim.treesitter.start()"
|
|
||||||
|
|
||||||
local bufnr = child.fn.bufnr(tmp)
|
local bufnr = child.fn.bufnr(tmp)
|
||||||
if pos then
|
if pos then
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue