diff options
author | phanium <91544758+phanen@users.noreply.github.com> | 2024-12-18 22:37:12 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-12-18 06:37:12 -0800 |
commit | 888a803755c58db56b5b20fcf6b812de877056c9 (patch) | |
tree | 9ae29b9deab84e93a7f92759cf5d1dbd9782d46c /test/functional/plugin/lsp_spec.lua | |
parent | 07d5dc8938a7f5d8cf2b702ef4f26af926b6ac45 (diff) | |
download | rneovim-888a803755c58db56b5b20fcf6b812de877056c9.tar.gz rneovim-888a803755c58db56b5b20fcf6b812de877056c9.tar.bz2 rneovim-888a803755c58db56b5b20fcf6b812de877056c9.zip |
fix(lsp): vim.lsp.start fails if existing client has no workspace_folders #31608
Problem:
regression since https://github.com/neovim/neovim/pull/31340
`nvim -l repro.lua`:
```lua
vim.lsp.start { cmd = { 'lua-language-server' }, name = 'lua_ls' }
vim.lsp.start { cmd = { 'lua-language-server' }, name = 'lua_ls', root_dir = 'foo' }
-- swapped case will be ok:
-- vim.lsp.start { cmd = { 'lua-language-server' }, name = 'lua_ls', root_dir = 'foo' }
-- vim.lsp.start { cmd = { 'lua-language-server' }, name = 'lua_ls' }
```
Failure:
```
E5113: Error while calling lua chunk: /…/lua/vim/lsp.lua:214: bad argument #1 to
'ipairs' (table expected, got nil)
stack traceback:
[C]: in function 'ipairs'
/…/lua/vim/lsp.lua:214: in function 'reuse_client'
/…/lua/vim/lsp.lua:629: in function 'start'
repro.lua:34: in main chunk
```
Diffstat (limited to 'test/functional/plugin/lsp_spec.lua')
-rw-r--r-- | test/functional/plugin/lsp_spec.lua | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/test/functional/plugin/lsp_spec.lua b/test/functional/plugin/lsp_spec.lua index d2ef166983..1f246b0914 100644 --- a/test/functional/plugin/lsp_spec.lua +++ b/test/functional/plugin/lsp_spec.lua @@ -1854,6 +1854,20 @@ describe('LSP', function() end, } end) + + it('vim.lsp.start when existing client has no workspace_folders', function() + exec_lua(create_server_definition) + eq( + { 2, 'foo', 'foo' }, + exec_lua(function() + local server = _G._create_server() + vim.lsp.start { cmd = server.cmd, name = 'foo' } + vim.lsp.start { cmd = server.cmd, name = 'foo', root_dir = 'bar' } + local foos = vim.lsp.get_clients() + return { #foos, foos[1].name, foos[2].name } + end) + ) + end) end) describe('parsing tests', function() |