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
|
run: task docgen
|
||||||
|
|
||||||
- name: Diff
|
- 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]
|
os: [ubuntu-latest]
|
||||||
version:
|
version:
|
||||||
- stable
|
- stable
|
||||||
# - nightly # TODO: enable when stable
|
- nightly
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
steps:
|
steps:
|
||||||
- name: Install Task
|
- name: Install Task
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ tasks:
|
||||||
desc: run all tests
|
desc: run all tests
|
||||||
cmds:
|
cmds:
|
||||||
- |
|
- |
|
||||||
nvim --headless \
|
nvim --clean --headless \
|
||||||
-u ./scripts/minimal_init.lua \
|
-u ./scripts/minimal_init.lua \
|
||||||
-c "lua MiniTest.run()"
|
-c "lua MiniTest.run()"
|
||||||
|
|
||||||
|
|
@ -28,8 +28,7 @@ tasks:
|
||||||
desc: generate vimhelp
|
desc: generate vimhelp
|
||||||
cmds:
|
cmds:
|
||||||
- |
|
- |
|
||||||
nvim --noplugin \
|
nvim --clean --headless \
|
||||||
--headless \
|
|
||||||
-u "./scripts/minimal_init.lua" \
|
-u "./scripts/minimal_init.lua" \
|
||||||
-c "luafile ./scripts/docgen.lua" \
|
-c "luafile ./scripts/docgen.lua" \
|
||||||
-c ":qa!"
|
-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.
|
It's not an LSP tool, the main goal of this plugin is add go tooling support in Neovim.
|
||||||
|
|
||||||
Table of Contents
|
Table of Contents
|
||||||
Setup..................................................|gopher.nvim-setup()|
|
Setup ................................................ |gopher.nvim-setup()|
|
||||||
Install dependencies..............................|gopher.nvim-dependencies|
|
Install dependencies ............................ |gopher.nvim-dependencies|
|
||||||
Config..................................................|gopher.nvim-config|
|
Config ................................................ |gopher.nvim-config|
|
||||||
Commands..............................................|gopher.nvim-commands|
|
Commands ............................................ |gopher.nvim-commands|
|
||||||
Modify struct tags.................................|gopher.nvim-struct-tags|
|
Modify struct tags ............................... |gopher.nvim-struct-tags|
|
||||||
Auto implementation of interface methods..................|gopher.nvim-impl|
|
Auto implementation of interface methods ................ |gopher.nvim-impl|
|
||||||
Generating unit tests boilerplate......................|gopher.nvim-gotests|
|
Generating unit tests boilerplate .................... |gopher.nvim-gotests|
|
||||||
Iferr....................................................|gopher.nvim-iferr|
|
Iferr .................................................. |gopher.nvim-iferr|
|
||||||
Generate comments.....................................|gopher.nvim-comments|
|
Generate comments ................................... |gopher.nvim-comments|
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
*gopher.nvim-setup()*
|
*gopher.nvim-setup()*
|
||||||
|
|
|
||||||
|
|
@ -50,18 +50,15 @@ end
|
||||||
---@return {name:string, is_varstruct:boolean}
|
---@return {name:string, is_varstruct:boolean}
|
||||||
local function get_captures(query, node, bufnr)
|
local function get_captures(query, node, bufnr)
|
||||||
local res = {}
|
local res = {}
|
||||||
for _, match, _ in query:iter_matches(node, bufnr) do
|
for id, _node in query:iter_captures(node, bufnr) do
|
||||||
for capture_id, captured_node in pairs(match) do
|
if query.captures[id] == "_name" then
|
||||||
local capture_name = query.captures[capture_id]
|
res["name"] = vim.treesitter.get_node_text(_node, bufnr)
|
||||||
if capture_name == "_name" then
|
|
||||||
res["name"] = vim.treesitter.get_node_text(captured_node, bufnr)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if capture_name == "_var" then
|
if query.captures[id] == "_var" then
|
||||||
res["is_varstruct"] = true
|
res["is_varstruct"] = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
return res
|
return res
|
||||||
end
|
end
|
||||||
|
|
@ -77,6 +74,10 @@ end
|
||||||
---@param query string
|
---@param query string
|
||||||
---@return gopher.TsResult
|
---@return gopher.TsResult
|
||||||
local function do_stuff(bufnr, parent_type, query)
|
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 {
|
local node = vim.treesitter.get_node {
|
||||||
bufnr = bufnr,
|
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_STATE_HOME = root ".tests/state"
|
||||||
vim.env.XDG_CACHE_HOME = root ".tests/cache"
|
vim.env.XDG_CACHE_HOME = root ".tests/cache"
|
||||||
|
|
||||||
vim.cmd [[set runtimepath=$VIMRUNTIME]]
|
|
||||||
vim.opt.runtimepath:append(root())
|
vim.opt.runtimepath:append(root())
|
||||||
vim.opt.packpath = { root ".tests/site" }
|
vim.opt.packpath:append(root ".tests/site")
|
||||||
vim.notify = vim.print
|
vim.notify = vim.print
|
||||||
|
|
||||||
-- install go treesitter parse
|
-- install go treesitter parse
|
||||||
|
|
@ -53,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,
|
||||||
|
})
|
||||||
|
|
|
||||||
|
|
@ -69,6 +69,7 @@ end
|
||||||
---@class gopher.TestUtilsSetup
|
---@class gopher.TestUtilsSetup
|
||||||
---@field tmp string
|
---@field tmp string
|
||||||
---@field fixtures gopher.TestUtilsFixtures
|
---@field fixtures gopher.TestUtilsFixtures
|
||||||
|
---@field bufnr number
|
||||||
|
|
||||||
---@param fixture string
|
---@param fixture string
|
||||||
---@param child MiniTest.child
|
---@param child MiniTest.child
|
||||||
|
|
@ -81,12 +82,14 @@ 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)
|
||||||
|
|
||||||
|
local bufnr = child.fn.bufnr(tmp)
|
||||||
if pos then
|
if pos then
|
||||||
child.fn.setpos(".", { child.fn.bufnr(tmp), unpack(pos) })
|
child.fn.setpos(".", { bufnr, unpack(pos) })
|
||||||
end
|
end
|
||||||
|
|
||||||
return {
|
return {
|
||||||
tmp = tmp,
|
tmp = tmp,
|
||||||
|
bufnr = bufnr,
|
||||||
fixtures = fixtures,
|
fixtures = fixtures,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue