github workflow and reference spec test

neovim_0_5
ray-x 3 years ago
parent b292c2b981
commit 72e0b4e1e4

@ -263,13 +263,22 @@ together. If you have multiple similar LSP installed and have trouble with the p
### Disable a lsp client loading from navigator
To disable a specific LSP, set `filetypes` to {} e.g.
```lua
```lua
require'navigator'.setup({
pyls={filetype={}}
})
```
Or:
```lua
require'navigator'.setup({
disable_lsp = {'pyls', 'sqlls'},
})
```
### Default keymaps
| mode | key | function |

@ -11,8 +11,8 @@ local locations_to_items = lsphelper.locations_to_items
local function ref_hdlr(err, api, locations, num, bufnr)
local opts = {}
-- log("arg1", arg1)
-- log(api)
trace("arg1", err, api, locations, num, bufnr)
log(api)
trace(locations)
-- log("num", num)
-- log("bfnr", bufnr)
@ -38,13 +38,16 @@ local function ref_hdlr(err, api, locations, num, bufnr)
local wwidth = vim.api.nvim_get_option("columns")
local mwidth = _NgConfigValues.width
width = math.min(width + 30, 120, math.floor(wwidth * mwidth))
return gui.new_list_view({
-- log(items)
-- log(width)
local listview = gui.new_list_view({
items = items,
ft = ft,
width = width,
api = "Reference",
enable_preview_edit = true
})
return listview, items, width
end
local async_reference_request = function()

@ -0,0 +1,3 @@
module github.com/navigator/tests
go 1.17

@ -0,0 +1,72 @@
package main
import (
"fmt"
"math"
//"math"
)
type geometry interface {
area() float64
perim() float64
}
type rect struct {
width float64 `-line:"width"`
height float64 `-line:"height"`
}
type rect2 struct {
width int `yml:"width"`
height int `yml:"height"`
}
func (r rect) area() float64 {
return r.width * r.height
}
func (r rect) perim() float64 {
return 2*r.width + 2*r.height
}
type circle struct {
radius float64
}
func (c circle) area() float64 {
return math.Pi * c.radius * c.radius
}
func (c circle) perim() float64 {
return 2 * math.Pi * c.radius
}
func measure(g geometry) int {
fmt.Println(g)
fmt.Println(g.area())
fmt.Println(g.perim())
return 1
}
func m2() {
measure(rect{width: 3})
}
func M2() {
measure(rect{width: 3})
}
func runinterface() {
r := rect{width: 3, height: 4}
c := circle{radius: 5}
measure(r)
measure(c)
d := circle{radius: 10}
fmt.Println(d)
}
func main() {
M2()
m2()
runinterface()
}

@ -0,0 +1,12 @@
package main
import "fmt"
func interfaceTest() {
r := rect{width: 3, height: 4}
c := circle{radius: 5}
measure(r)
measure(c)
d := circle{radius: 10}
fmt.Println(d)
}

@ -1,9 +1,13 @@
set rtp +=.
set rtp +=../plenary.nvim/
set rtp +=../nvim-treesitter/
set rtp +=../guihua.lua/
set rtp +=../navigator.lua/
runtime! plugin/plenary.vim
runtime! plugin/nvim-treesitter.vim
runtime! plugin/guihua.vim
runtime! plugin/navigator.vim
set noswapfile
set nobackup
@ -20,5 +24,18 @@ lua << EOF
_G.test_rename = true
_G.test_close = true
require("plenary/busted")
require("navigator").setup()
require'nvim-treesitter.configs'.setup {
ensure_installed = {"go"}, -- one of "all", "maintained" (parsers with maintainers), or a list of languages
highlight = {
enable = true, -- false will disable the whole extension
},
}
require'navigator'.setup({
debug = false, -- log output, set to true and log path: ~/.local/share/nvim/gh.log
code_action_icon = " ",
width = 0.75, -- max width ratio (number of cols for the floating window) / (window width)
height = 0.3, -- max list window height, 0.3 by default
preview_height = 0.35, -- max height of preview windows
border = 'none',
})
EOF

@ -0,0 +1,98 @@
local helpers = {}
local busted = require("plenary/busted")
local eq = assert.are.same
local cur_dir = vim.fn.expand("%:p:h")
-- local status = require("plenary.reload").reload_module("go.nvim")
-- status = require("plenary.reload").reload_module("nvim-treesitter")
-- local ulog = require('go.utils').log
describe("should run lsp reference", 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")
it("should show references", function()
local status = require("plenary.reload").reload_module("navigator")
local status = require("plenary.reload").reload_module("guihua")
vim.cmd([[packadd navigator.lua]])
vim.cmd([[packadd guihua.lua]])
local path = cur_dir .. "/tests/fixtures/interface.go" -- %:p:h ? %:p
local cmd = " silent exe 'e " .. path .. "'"
vim.cmd(cmd)
vim.cmd([[cd %:p:h]])
local bufn = vim.fn.bufnr("")
require'navigator'.setup({
debug = false, -- log output, set to true and log path: ~/.local/share/nvim/gh.log
code_action_icon = "A ",
width = 0.75, -- max width ratio (number of cols for the floating window) / (window width)
height = 0.3, -- max list window height, 0.3 by default
preview_height = 0.35, -- max height of preview windows
border = 'none'
})
vim.fn.setpos(".", {bufn, 15, 4, 0}) -- width
vim.bo.filetype = "go"
vim.lsp.buf.references()
eq(1, 1)
end)
it("reference handler should return items", function()
local status = require("plenary.reload").reload_module("navigator")
local status = require("plenary.reload").reload_module("guihua")
vim.cmd([[packadd navigator.lua]])
vim.cmd([[packadd guihua.lua]])
local path = cur_dir .. "/tests/fixtures/interface.go" -- %:p:h ? %:p
print(path)
local cmd = " silent exe 'e " .. path .. "'"
vim.cmd(cmd)
vim.cmd([[cd %:p:h]])
local bufn = vim.fn.bufnr("")
vim.fn.setpos(".", {bufn, 15, 4, 0}) -- width
vim.bo.filetype = "go"
require'navigator'.setup({
debug = false, -- log output, set to true and log path: ~/.local/share/nvim/gh.log
code_action_icon = "A ",
width = 0.75, -- max width ratio (number of cols for the floating window) / (window width)
height = 0.3, -- max list window height, 0.3 by default
preview_height = 0.35, -- max height of preview windows
border = 'none'
})
local result = {
{
range = {['end'] = {character = 6, line = 14}, start = {character = 1, line = 14}},
uri = "file://" .. cur_dir .. "/tests/fixtures/interface.go"
}, {
range = {['end'] = {character = 15, line = 24}, start = {character = 10, line = 24}},
uri = "file://" .. cur_dir .. "/tests/fixtures/interface.go"
}, {
range = {['end'] = {character = 17, line = 28}, start = {character = 12, line = 28}},
uri = "file://" .. cur_dir .. "/tests/fixtures/interface.go"
}, {
range = {['end'] = {character = 19, line = 51}, start = {character = 14, line = 51}},
uri = "file://" .. cur_dir .. "/tests/fixtures/interface.go"
}, {
range = {['end'] = {character = 19, line = 55}, start = {character = 14, line = 55}},
uri = "file://" .. cur_dir .. "/tests/fixtures/interface.go"
}, {
range = {['end'] = {character = 16, line = 59}, start = {character = 11, line = 59}},
uri = "file://" .. cur_dir .. "/tests/fixtures/interface.go"
}, {
range = {['end'] = {character = 16, line = 5}, start = {character = 11, line = 5}},
uri = "file://" .. cur_dir .. "/tests/fixtures/interface_test.go"
}
}
local win, items, width = require('navigator.reference').reference_handler(nil,
"textDocument/references",
result, 1, 1)
eq(win.ctrl.data[1].display_filename, "./interface.go")
eq(win.ctrl.data[2].range.start.line, 14)
eq(items[1].display_filename, "./interface.go")
eq(width, 60)
end)
end)
Loading…
Cancel
Save