-
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
sumneko_lua
doesn't work across multiple projects
#2366
Comments
you should define a handler for vim.lsp.handlers['workspace/diagnostic/refresh'] = function(_, _, ctx)
local ns = vim.lsp.diagnostic.get_namespace(ctx.client_id)
local bufnr = vim.api.nvim_get_current_buf()
vim.diagnostic.reset(ns, bufnr)
return true
end
|
That helped get rid of the undefined issue for |
can't reproduce that I used for some days it works fine for me . |
Have you tried the |
your sumneko server workspace config ? |
What do you mean? The |
please try to config the sumneko lua-language server workspace field. |
If you're talking about In any case, please do re-open the issue so that it's visible to anyone else who is experiencing the same problem. Also, can you tell me the neovim and sumneko_lua version you're using? |
head version and latest version. can you try do |
Tried it, doesn't work. I also tried to edit the file and press |
Can you try |
Also, can you check |
wired. how to reproduce ? my gif just show you reproduce step 🥲 |
Never mind that. Workspace folders doesn't actually work properly before that commit. |
Alright, I found a commit where it actually works: 6eb24ef |
I don't think so .that commit not correct. it not send request to client when the workspace changed. |
Ah, you're right... |
I still need a reproduce step on my local 😺 looks useful that issue. |
Reproduce step? |
yes. your reproduce step works fine for me . Open a Lua project.
Open a different Lua project from a different root directory, without closing the current nvim session. |
Yes, I'm not sure why it's not working on my machine... |
lua language version is same . there still has a thing that I wondered is the server said the lua workspace not support dynamically.
but how to restart. we only have stop and start function. stop will close this process. so the restart server mean what ? use new config start client with attatched buffers and new workspaceFolders value or something else ? btw I don't read the lua language server code someone told me that support dynamically workspace .. https://github.com/sumneko/lua-language-server/wiki/Developing#multiple-workspace-support |
Right, that note also caught my attention. |
looks like something wrong in there
|
Is it the |
You can ignore everything I just said, lspconfig in lunarvim is outdated, it works with a newer version |
|
|
Never mind, |
Ok, I tried out VSCode now and it seems that what they do is that they restart the server from a scratch every time a new folder is added to the workspace. At least in the case of lua-language-server, this is what they do. |
as
like i said in there .doc said it need restart. but for other server what should we do ? both restart or only restart lua server? |
Yeah, I'm not sure how other LSP extensions handle it either. I've only tried sumneko on VSCode. |
restart it easy just copy the old |
Right, I suppose we can just setup a manual rule/exception list for workspace restart behaviors. |
yup I saw that code .but don't know how does it works. maybe for future or next version ? create an issue on sumnkeo lua for that would be better. in there currently add a field in sumneko lua config maybe called |
Yeah, sounds like a good idea. |
|
What do you mean by not using these values? |
check #2383 |
did anyone file an issue with sumneko...? |
@glepnir I am having the same issue, if i open two different projects, both different .git repos, i get sumneko attached to the first project root, if i then open a file from the other project, sumneko attaches to that buffer/file but the root_dir of the instance stays the same, the same behaviour i can observe for yamlls as well. I would expect that either sumneko and yamls is notified when i change contexts / projects or two instances should be run, one for each project. My setup is just calling lspconfig["yamlls"].setup({}) same for lua_ls (sumneko) |
Yes, i just tested it it does work okay with lua_ls, but my question about yamlls remains, should i open a new ticket ? |
I think a part of this issue have re-surfaced again and the handler doesn't even help. I'm getting undefined globals when I open a new project root. |
I don't know what's going on, i just tested it a few days ago, and it was working just fine with lua_ls, now it is broken again, for reference, seems like the root dir is changing but, could be async, as i am using bufenter to read the client's root dir from the config, to set the cwd for nvim. Just to make sure i am also testing bashls to make sure i am not insane, and bashls for example works just fine when you jump between files from different working dirs. But maybe that is not a reliable way |
luals attach function client.capabilities. workspace.diagnostics.supportRefresh = true |
What do you mean? I am also having the same problem as others are describing. The root directory is correct but I get a lot of undefined globals and the handler for |
Here is a video: Screencast.from.24.feb.2023.kl.13.07.+0100.webm |
Description
sumneko_lua
simply doesn't work across multiple projects. The LSP is only working for the first project you opened, but it will stop for working for any subsequent projects.Neovim version
NVIM v0.9.0-dev-484+gb5edea655
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Compiled by runneradmin@fv-az368-865
Nvim-lspconfig version
4329350
Operating system and version
Windows 10
Affected language servers
sumneko_lua
Steps to reproduce
nvim -nu minimal_init.lua
Actual behavior
The first opened project works fine. But the subsequently opened projects are completely non-functional.
Trying to open the hover menu with
K
will give youWorkspace loading: 0/0
permanently.Even the
require
statement is considered to beundefined
.I'm guessing this is because of the new workspace folders feature added by the recent commits. But I did remember testing the workspace functionality when it was first introduced to
lspconfig
and it worked perfectly fine.But after some time, it just stopped working. I suppose there was a recent commit that broke the feature, but I can't quite narrow it down.
Expected behavior
The subsequently opened projects should work just as fine as the first one.
Minimal config
LSP log
https://gist.github.com/musjj/1bf79a2c43957ff4c11cd92e74815145
The text was updated successfully, but these errors were encountered: