LuaLS / LuaLS/lua-language-server
Renamed file considered deleted inside directory junction
还没有人认领这个 Issue。
- 主要语言
- Lua
- 星标
- 4.4k
- 派生
- 442
- PR 合并指标
- 30 天内没有已合并 PR
描述
How are you using the lua-language-server?
NeoVim
Which OS are you using?
Windows
What is the issue affecting?
Other
Expected Behaviour
LS correctly works with files inside directory junction or symlinks.
Actual Behaviour
LS functionality stops working after saving such a file in editor.
Reproduction steps
- Enable LuaLS in NeoVim.
- Put NeoVim config files inside directory junction. E.g. I have
init.luafile in directoryC:\dev\dotfiles\nvimand I've created the junction to that directory inC:\Users\RobotComp.ru\AppData\Local\nvim. NVim reads config files fromC:\Users\RobotComp.ru\AppData\Local\nvim. - Open
init.luain NVim, change something and save it with:wcommand. - After that, any interactions with LS stop working (hover, go to definition, etc.)
- If I re-edit file with
:e %command, everything starts working again.
Additional Notes
I did some research and found the following.
When saving init.lua, NVim renames it several times (to init.lua~ and back). Don't know why.
The logs (see error.log) show that the filewatch(rename) function is called on LS, which calls isExists().
And although the file exists, isExists() returns false, so the file is considered deleted, and the LS "forgets" about it.
More specifically, the problem occurs in script/filewatch.lua:18:
if res :string():gsub('^%w+:', string.lower)
~= path:string():gsub('^%w+:', string.lower) then
return false
end
Here, it turns out that res contains the actual path to the file (C:\dev\dotfiles\nvim\init.lua), and path contains the path with the junction (C:\Users\RobotComp.ru\AppData\Local\nvim\init.lua).
Commenting out these lines makes everything work correctly (see fixed.log). However, I didn't make a PR with such changes because I didn't fully understand why this path comparison was needed at all. It seems like it fixes some other bug?
Thanks in advance :)
Log File
[00:20:20.415][debug][#0:script\filewatch.lua:98]: filewatch: rename C:\Users\RobotComp.ru\AppData\Local\nvim\init.lua
[00:20:20.415][debug][#0:script\filewatch.lua:98]: filewatch: modify C:\Users\RobotComp.ru\AppData\Local\nvim\init.lua
[00:20:20.415][debug][#0:script\filewatch.lua:98]: filewatch: rename C:\Users\RobotComp.ru\AppData\Local\nvim\init.lua~
[00:20:20.415][debug][#0:script\workspace\workspace.lua:592]: FileChangeType.Deleted file:///c%3A/Users/RobotComp.ru/AppData/Local/nvim/init.lua
[00:20:20.416][debug][#0:script\workspace\workspace.lua:592]: FileChangeType.Deleted file:///c%3A/Users/RobotComp.ru/AppData/Local/nvim/init.lua~
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
在 Windows 上使用通过目录联接存储的 NeoVim 配置重现该问题,然后阅读 script/filewatch.lua:18,并跟进日志中显示的重命名处理。完成的标准是:保存 init.lua 不再导致 language server 将联接路径视为已删除,同时 hover 和 go-to-definition 继续正常工作。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- lua, neovim
- 领域
- tooling
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 48/100