fix: nightly(0.11) (#104)
* chore: fix minimal_init, load default plugins correctly * refactor(ts): make it work on nightly * chore: get nightly back in ci * fix(tests): some how i now i need to run vim.treesitter.start() to make it work * feat(ts): check if parser is found * chore: use --clean instead --noplugin * refactor(tests): use auto commands instead of putting it in each test * chore: show the diff of the doc
This commit is contained in:
parent
c0b2834652
commit
77754fe362
7 changed files with 39 additions and 26 deletions
4
.github/workflows/linters.yml
vendored
4
.github/workflows/linters.yml
vendored
|
|
@ -53,4 +53,6 @@ jobs:
|
|||
run: task docgen
|
||||
|
||||
- name: Diff
|
||||
run: exit $(git status --porcelain doc | wc -l | tr -d " ")
|
||||
run: |
|
||||
git diff doc
|
||||
exit $(git status --porcelain doc | wc -l | tr -d " ")
|
||||
|
|
|
|||
2
.github/workflows/tests.yml
vendored
2
.github/workflows/tests.yml
vendored
|
|
@ -14,7 +14,7 @@ jobs:
|
|||
os: [ubuntu-latest]
|
||||
version:
|
||||
- stable
|
||||
# - nightly # TODO: enable when stable
|
||||
- nightly
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- name: Install Task
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ tasks:
|
|||
desc: run all tests
|
||||
cmds:
|
||||
- |
|
||||
nvim --headless \
|
||||
nvim --clean --headless \
|
||||
-u ./scripts/minimal_init.lua \
|
||||
-c "lua MiniTest.run()"
|
||||
|
||||
|
|
@ -28,8 +28,7 @@ tasks:
|
|||
desc: generate vimhelp
|
||||
cmds:
|
||||
- |
|
||||
nvim --noplugin \
|
||||
--headless \
|
||||
nvim --clean --headless \
|
||||
-u "./scripts/minimal_init.lua" \
|
||||
-c "luafile ./scripts/docgen.lua" \
|
||||
-c ":qa!"
|
||||
|
|
|
|||
|
|
@ -8,15 +8,15 @@ gopher.nvim is a minimalistic plugin for Go development in Neovim written in Lua
|
|||
It's not an LSP tool, the main goal of this plugin is add go tooling support in Neovim.
|
||||
|
||||
Table of Contents
|
||||
Setup..................................................|gopher.nvim-setup()|
|
||||
Install dependencies..............................|gopher.nvim-dependencies|
|
||||
Config..................................................|gopher.nvim-config|
|
||||
Commands..............................................|gopher.nvim-commands|
|
||||
Modify struct tags.................................|gopher.nvim-struct-tags|
|
||||
Auto implementation of interface methods..................|gopher.nvim-impl|
|
||||
Generating unit tests boilerplate......................|gopher.nvim-gotests|
|
||||
Iferr....................................................|gopher.nvim-iferr|
|
||||
Generate comments.....................................|gopher.nvim-comments|
|
||||
Setup ................................................ |gopher.nvim-setup()|
|
||||
Install dependencies ............................ |gopher.nvim-dependencies|
|
||||
Config ................................................ |gopher.nvim-config|
|
||||
Commands ............................................ |gopher.nvim-commands|
|
||||
Modify struct tags ............................... |gopher.nvim-struct-tags|
|
||||
Auto implementation of interface methods ................ |gopher.nvim-impl|
|
||||
Generating unit tests boilerplate .................... |gopher.nvim-gotests|
|
||||
Iferr .................................................. |gopher.nvim-iferr|
|
||||
Generate comments ................................... |gopher.nvim-comments|
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
*gopher.nvim-setup()*
|
||||
|
|
|
|||
|
|
@ -50,16 +50,13 @@ end
|
|||
---@return {name:string, is_varstruct:boolean}
|
||||
local function get_captures(query, node, bufnr)
|
||||
local res = {}
|
||||
for _, match, _ in query:iter_matches(node, bufnr) do
|
||||
for capture_id, captured_node in pairs(match) do
|
||||
local capture_name = query.captures[capture_id]
|
||||
if capture_name == "_name" then
|
||||
res["name"] = vim.treesitter.get_node_text(captured_node, bufnr)
|
||||
end
|
||||
for id, _node in query:iter_captures(node, bufnr) do
|
||||
if query.captures[id] == "_name" then
|
||||
res["name"] = vim.treesitter.get_node_text(_node, bufnr)
|
||||
end
|
||||
|
||||
if capture_name == "_var" then
|
||||
res["is_varstruct"] = true
|
||||
end
|
||||
if query.captures[id] == "_var" then
|
||||
res["is_varstruct"] = true
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -77,6 +74,10 @@ end
|
|||
---@param query string
|
||||
---@return gopher.TsResult
|
||||
local function do_stuff(bufnr, parent_type, query)
|
||||
if not vim.treesitter.get_parser(bufnr, "go") then
|
||||
error "No treesitter parser found for go"
|
||||
end
|
||||
|
||||
local node = vim.treesitter.get_node {
|
||||
bufnr = bufnr,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,9 +30,8 @@ vim.env.XDG_DATA_HOME = root ".tests/data"
|
|||
vim.env.XDG_STATE_HOME = root ".tests/state"
|
||||
vim.env.XDG_CACHE_HOME = root ".tests/cache"
|
||||
|
||||
vim.cmd [[set runtimepath=$VIMRUNTIME]]
|
||||
vim.opt.runtimepath:append(root())
|
||||
vim.opt.packpath = { root ".tests/site" }
|
||||
vim.opt.packpath:append(root ".tests/site")
|
||||
vim.notify = vim.print
|
||||
|
||||
-- install go treesitter parse
|
||||
|
|
@ -53,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,
|
||||
})
|
||||
|
|
|
|||
|
|
@ -69,6 +69,7 @@ end
|
|||
---@class gopher.TestUtilsSetup
|
||||
---@field tmp string
|
||||
---@field fixtures gopher.TestUtilsFixtures
|
||||
---@field bufnr number
|
||||
|
||||
---@param fixture string
|
||||
---@param child MiniTest.child
|
||||
|
|
@ -81,12 +82,14 @@ function testutils.setup_test(fixture, child, pos)
|
|||
testutils.writefile(tmp, fixtures.input)
|
||||
child.cmd("silent edit " .. tmp)
|
||||
|
||||
local bufnr = child.fn.bufnr(tmp)
|
||||
if pos then
|
||||
child.fn.setpos(".", { child.fn.bufnr(tmp), unpack(pos) })
|
||||
child.fn.setpos(".", { bufnr, unpack(pos) })
|
||||
end
|
||||
|
||||
return {
|
||||
tmp = tmp,
|
||||
bufnr = bufnr,
|
||||
fixtures = fixtures,
|
||||
}
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue