-
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
bug(lua_ls): incorrect root_dir due to early return when root_files is found which ignore longer root_git (and root_lua) #3508
Comments
Thanks for the very clear report.
Good point. Are you suggesting that we remove or reorder the condition, or what exactly? Glancing at the logic, it does seem strange that we try Also, if "choose the longest (i.e. innermost) path" is the right approach, why don't we do that for all configs instead of only this one? What are your thoughts @pitkling @mangkoran |
Thank you for your reply.
I'm thinking of comparing these 3 (
If by "all configs" you mean all LSP configs, honestly I'm not really sure if this is also applicable for all configs as I don't use every LSP in this repo. It's just coincidence that this issue happened when I used For this particular issue/lsp, my suggestion has been stated above. What do you think? |
This commit doesn't address the case when root path == vim.env.HOME as the case lack return when it's true (neovim#2110) Fix neovim#3508
I completely agree with @mangkoran here. From my experience with Lua, I would also expect that the LSP simply takes the longest among all candidate paths as root dir. So I think the suggested change makes sense for the Lua LSP. And similarly, while I personally think it's probably a very good approximation for almost all LSPs to use the longest path as root dir if there are multiple candidates (due to different types of indicator files), I could imagine that
So not sure whether the (maybe) better default behavior is worth the potential problems it might cause to change this for all LSPs. |
A counter point for longest path is |
@justinmk @lithammer I think for now we could fix this for |
Sounds reasonable to me. |
What does this even mean? Is the |
Yes it's supposed to be parent directory. It's just to cut short/abbreviate the full parent directory path 😅 You could refer to the tree diagram for the full directory structure. |
Oh, as in ellipsis. So |
Description
The issue is similar to #3165 but now it seems it's caused by
root_files
. The issue occurs with the following directory structure:Whenever I open a file under
../SomeProjectWithLuaFiles/
, I expectroot_dir
is set to../SomeProjectWithLuaFiles/
. However somehowroot_dir
is set toHOME/workspaces/
. After quick investigation, it seemsstylua.toml
makes the LSP setroot_dir
toHOME/workspaces/
because after I removedstylua.toml
theroot_dir
is now../SomeProjectWithLuaFiles/
. Looking atlua_ls
config, it seems this is caused by early return from the following lines:nvim-lspconfig/lua/lspconfig/configs/lua_ls.lua
Lines 19 to 21 in 3cb6c05
#3322 suggest setting
root_dir
to the longer root path if both a.git
- and alua
-ancestor are found, which is not satisfied in this case.Please let me know if this is confirmed to be an issue. I am happy to help with a PR.
The text was updated successfully, but these errors were encountered: