LuaLS / LuaLS/lua-language-server
VS Code variable resolution in @source annotations/relativity of paths
还没有人认领这个 Issue。
- 主要语言
- Lua
- 星标
- 4.4k
- 派生
- 442
- PR 合并指标
- 30 天内没有已合并 PR
描述
How are you using the lua-language-server?
Visual Studio Code Extension (sumneko.lua)
Which OS are you using?
Linux
What is the issue affecting?
Diagnostics/Syntax Checking
Expected Behaviour
Intuitively, I expected:
---@sourceannotations in meta files with relative paths to be resolved relative to the workspace- VS Code variables in the
@sourcepath to be resolved when resolving a path
Actual Behaviour
@sourcepaths are resolved relative to the meta file itself- VS Code variables in the path are not resolved
Reproduction steps
- Create
.vscode/luals/library/foo.d.luawith:---@meta --- @class foo _G.foo = {} ---@source grault/foo.lua:1 function bar() end - Create
baz.luawith:require("foo") local quux = foo.bar() - In extension settings, set:
{ "Lua.workspace.userThirdParty": ["${fileWorkspaceFolder}/LuaLS"] }
[!NOTE]
The variable ${fileWorkspaceFolder} resolves correctly and adds the meta file to the list of search paths
- Open
baz.luain VS Code editor - Right click
bar - Select
Go to Definition - Observe:
VS Code opens a non-existent source file tab to.vscode/luals/library/grault/foo.lua
Additional Notes
This could be two separate issues, but they're tightly related -- one as a Documentation Issue that the relativity of the resolution of the path should be added to the docs, and two as a Bug/Feature Request that VS Code variables be resolved in the @source paths as they are in the settings
Attempting to work around this using VS Code variables has the variable unresolved and taken literally. For example, setting the @source path to /${fileWorkspaceFolder}/grault/foo.lua:1 causes VS Code to open a tab to that literal string instead of the expected /home/me/my_project/grault/foo.lua:1
Log File
No response
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
使用 .vscode/luals/library/foo.d.lua、baz.lua 和 workspace.userThirdParty 设置复现该示例。首先跟踪 @source 路径的解析方式以及 VS Code 变量的展开方式,然后对照预期的 Go to Definition 目标验证相对路径行为和变量替换。若所选的路径相对性保持不变,请记录下来。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- lua, vscode
- 领域
- devtools
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 冷清
- 描述清晰度
- 基本清楚
- 新手友好度
- 55/100