refactor(tests): use auto commands instead of putting it in each test

This commit is contained in:
Oleksandr Smirnov 2025-03-23 18:49:49 +02:00
parent 9d734f114d
commit c0297ac1d6
No known key found for this signature in database
3 changed files with 9 additions and 5 deletions

View file

@ -52,3 +52,12 @@ if #vim.api.nvim_list_uis() == 0 then
},
}
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,
})

View file

@ -44,16 +44,12 @@ T["struct_tags"]["should add more than one tag"] = function()
--- with comma, like gomodifytags
child.cmd("silent edit " .. tmp)
child.lua "vim.treesitter.start()"
child.fn.setpos(".", { child.fn.bufnr(tmp), 3, 1 })
child.cmd "GoTagAdd test4,test5"
child.cmd "write"
-- without comma
child.cmd("silent edit " .. tmp)
child.lua "vim.treesitter.start()"
child.fn.setpos(".", { child.fn.bufnr(tmp), 3, 1 })
child.cmd "GoTagAdd test1 test2"
child.cmd "write"

View file

@ -81,7 +81,6 @@ function testutils.setup_test(fixture, child, pos)
testutils.writefile(tmp, fixtures.input)
child.cmd("silent edit " .. tmp)
child.lua "vim.treesitter.start()"
local bufnr = child.fn.bufnr(tmp)
if pos then