-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multi workspace support for sumneko_lua
#2302
Comments
Did a quick look through the code, and it seems that this is a bug caused by treating nvim-lspconfig/lua/lspconfig/util.lua Lines 253 to 263 in 8a3e5f9
When it is properly treated, multi workspace now works (the list of workspace folders also have to be checked and initialized): local _, id = next(clients)
if id then
local client = lsp.get_client_by_id(id)
if client.name == new_config.name then
local params = lsp.util.make_workspace_params(
{ { uri = vim.uri_from_fname(root_dir), name = root_dir } },
{ {} }
)
client.workspace_folders = client.workspace_folders or {}
table.insert(client.workspace_folders, params.event.added[1])
return id
end
end |
yes that's a key-value table. thanks for point it out. now should works fine. |
Is this the intended behavior? Previously, if you opened a directory such as:
You would get a server for each project:
Now, opening the same project, you get:
Even when you're in a file in Ironically, I stumbled into this because I wanted to use the sumneko_lua behavior as a reference point to fix the problem in null-ls: |
seems like the clients store the null-ls not sumneko_lua so there still spawn the new lua server. |
Sorry, I don't follow. Previously (I was on |
I don't think spawn multiple servers is correct. it should use one instance with multiple workspacefolders. in your situation it should have one lua instance. when you open file1 in project 1 the proejct 1 will insert to worskpaceFolders . same as other projects. |
@glepnir nvim-lspconfig/lua/lspconfig/util.lua Line 261 in 3bb0c53
@ehaynes99 |
I will fix the root dir of lspinfo . it should show the correct path from workspace folders. |
@musj when it's nil it works as single_file_mode and it store in |
If |
@musjj @ehaynes99 check #2304 |
Do I need to explicitly do something to specify
For the second file in
I created the project above like below, then simply started #!/usr/bin/env bash
for i in 1 2 3
do
DIR="project${i}"
mkdir $DIR
pushd $DIR
git init .
touch example.lua
popd
done |
I used this, correct? { 'glepnir/nvim-lspconfig', branch = 'fixing' }, |
@ehaynes99 please update should be works fine now. |
Cool, looks good now! |
Language server
sumneko_lua
Requested feature
https://github.com/sumneko/lua-language-server/wiki/Developing#multiple-workspace-support
Is it possible to have a multi-workspace environment for
sumneko_lua
? AKA, a single LSP instance for multiple projects?I've also noticed this PR: #2287, does it have anything to do with this feature?
I'm on the latest lspconfig commit with the latest nvim nightly, but multiple Lua projects still spawn multiple LSP instances.
A few other related issues I've found:
#842
prabirshrestha/vim-lsp#1069
Other clients which have this feature
vim-lsp
The text was updated successfully, but these errors were encountered: