-
-
Notifications
You must be signed in to change notification settings - Fork 283
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
When workspace folders are specified, two workspaces are loaded. #1596
Comments
Related to #1089 |
Can be improved to lazyload |
@carsakiller I once wrote a wiki explaining why there are multiple progress bars, but I can't find it now |
I think that got combined into the Why is the Server Scanning the Wrong Folder? FAQ answer. |
I don't really remember seeing a progress bar section, but I'll take a look through the history |
I found this section from the old Excerpt多进度条/单文件模式|Multi progress bar/Single file mode在阅读接下来的内容之前,请先看一下 https://github.com/sumneko/lua-language-server/wiki/Multi-workspace-supports 当你以单文件模式启动服务器时,服务器只会创建 当你以工作区模式启动服务器时,服务器实际上会创建2个Scope,一个是你的工作区,另一个则是 由于我的开发环境是VSCode,而VSCode可以简单的为不同的工作区进行不同的设置,因此我做出了以下假设:
但最近的用户反馈让我发现了一个问题,在非VSCode环境中用户不方便给每个工作区进行单独设置(虽然我也提供了
介于这个情况,我在考虑添加一个默认开启的设置,使得 Please take a look before reading the following content: https://github.com/sumneko/lua-language-server/wiki/Multi-workspace-supports When you start the server in single file mode, the server will only create a When you start the server in workspace mode, the server will actually create two scopes, one is your workspace, and the other is the Since my development environment is VSCode, and VSCode can simply set different settings for different workspaces, I make the following assumptions:
However, I found a problem in the recent user feedback. In the non VSCode client, it is not convenient for users to set each workspace separately (although I provided
In this case, I'm considering adding a setting enabled by default, witch makes It looks like I forgot to include the progress bar part. This could be its own FAQ question. |
Yes |
Added as a new FAQ question 🙂 |
Awesome, thank you for the FAQ :) I'm looking to see how I can fix this in Neovim/lspconfig. It seems that the fallback (single file) config still indexes all files in the rootDir. |
But reading the FAQ, this is likely not a problem, since it will actually index every file only once? |
Yes, but I can consider changing into lazy loading or loading in turn, try not to show multiple progress bars. |
My understanding is that lua-language-server sends two A possible workaround is to teach neovim to look at local lspconfig = require 'lspconfig'
lspconfig.util.on_setup = lspconfig.util.add_hook_after(lspconfig.util.on_setup, function(config)
if config.name == 'lua_ls' then
-- workaround for nvim's incorrect handling of scopes in the workspace/configuration handler
-- https://github.com/folke/neodev.nvim/issues/41
-- https://github.com/LuaLS/lua-language-server/issues/1089
-- https://github.com/LuaLS/lua-language-server/issues/1596
config.handlers = vim.tbl_extend('error', {}, config.handlers)
config.handlers['workspace/configuration'] = function(...)
local _, result, ctx = ...
local client_id = ctx.client_id
local client = vim.lsp.get_client_by_id(client_id)
if client and client.workspace_folders and #client.workspace_folders then
if result.items and #result.items > 0 then
if not result.items[1].scopeUri then
return vim.tbl_map(function(_) return nil end, result.items)
end
end
end
return vim.lsp.handlers['workspace/configuration'](...)
end
end
end) But yeah, if lua-l-s could optionally ignore |
@liskin thank you for this workaround! In your opinion is this something we should apply for performance (or any other) reasons? Or is the only problem with the double loader the fact that the loader is shown twice in UI? as opposed to any actual performance impact? |
I just updated the workaround to a better version that only overrides the handlers for lua_ls to avoid interfering with other language servers.
Hm, I just tested this and it seems that there isn't actually any performance difference. I wouldn't have expected that :-) |
I just added something based on this to neodev: folke/neodev.nvim@c6be05a But indeed it probably doesn't make a difference performance wise, since luals won't index files multiple times. Either way, it will at least stop people reporting this issue for LazyVim, neodev etc.... |
@folke I still am having the problem with losing some of the global vim references after peeking a different file. I opened a new issue as requested here: folke/neodev.nvim#178 (repeating this message here as I find it hard sometimes to find comments within commits which is where I pinged you a few minutes ago here: folke/neodev.nvim@c6be05a#r137715953). |
the same issue . I think this need to solve |
https://github.com/sumneko/lua-language-server/blob/25acc18ff5ec25d5cf4a052dfba11c777847f86e/script/provider/provider.lua#L55
Shouldn't the
fallback
config only be loaded when#scope.folders == 0
?The text was updated successfully, but these errors were encountered: