lspconfig in spec test

pull/25/head
ray-x 3 years ago
parent 35f546fed1
commit 5a72a0ef31

@ -92,6 +92,31 @@ describe("should run gofmt", function()
cmd = "bd! " .. name
vim.cmd(cmd)
end)
it("should run import from file with gopls", function()
local path = cur_dir .. "/lua/tests/fixtures/fmt/goimports.go" -- %:p:h ? %:p
local expected = vim.fn.join(vim.fn.readfile(cur_dir
.. "/lua/tests/fixtures/fmt/goimports_golden.go"),
"\n")
require("go").setup({goimport = "gopls", lsp_cfg = true})
_GO_NVIM_CFG.goimport = 'gopls'
local name = vim.fn.tempname() .. ".go"
print(name)
local lines = vim.fn.readfile(path)
vim.fn.writefile(lines, name)
local cmd = " silent exe 'e " .. name .. "'"
vim.cmd(cmd)
vim.cmd([[cd %:p:h]])
require("go.format").goimport()
print("workspaces:", vim.inspect(vim.lsp.buf.list_workspace_folders()))
vim.wait(100, function()
end)
local fmt = vim.fn.join(vim.fn.readfile(name), "\n")
eq(expected, fmt)
cmd = "bd! " .. name
vim.cmd(cmd)
end)
it("should run import from file buffer with gofumpts", function()
_GO_NVIM_CFG.goimport = 'gofumports'
local path = cur_dir .. "/lua/tests/fixtures/fmt/goimports.go" -- %:p:h ? %:p

@ -1,6 +1,7 @@
set rtp +=.
set rtp +=../plenary.nvim/
set rtp +=../nvim-treesitter
set rtp +=../nvim-lspconfig/
runtime! plugin/plenary.vim
@ -8,7 +9,7 @@ lua vim.fn.setenv("DEBUG_PLENARY", true)
runtime! plugin/plenary.vim
runtime! plugin/nvim-treesitter.vim
runtime! plugin/playground.vim
runtime! plugin/nvim-autopairs.vim
runtime! plugin/nvim-lspconfig.vim
set noswapfile
set nobackup

Loading…
Cancel
Save