LuaLS / LuaLS/lua-language-server
Error when exporting Lua language server documentation
还没有人认领这个 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?
Windows
What is the issue affecting?
Other
Expected Behaviour
documentation export
Actual Behaviour
I encountered an error when trying to export documentation using the Lua language server (sumneko.lua-3.14.0):
[error]: script\cli\doc\export.lua:61: bad argument #1 to 'canonical' (bee::path expected, got nil)
Reproduction steps
- Install sumneko.lua-3.14.0 extension in VS Code
- Create a simple Lua project with documentation comments
- Try to export documentation (through command palette)
Additional Notes
This appears to be a regression or oversight in the extension where it attempts to use a variable before it's defined. The fix is straightforward and might help other users encountering the same issue.
Solution
I fixed this by modifying script\cli\doc\export.lua to define the DOC variable with a simpler fallback approach that doesn't rely on non-existent functions:
-- Define DOC variable to avoid nil error
local DOC = DOC or (ws.rootUri and fs.path(furi.decode(ws.rootUri)) or fs.current_path())
This simple fix ensures that DOC is always defined with a valid path value before it's used in the getLocalPath function, allowing the documentation export functionality to work properly.
Log File
[00:02:10.453][error][#0]: script\cli\doc\export.lua:61: bad argument #1 to 'canonical' (bee::path expected, got nil)
stack traceback:
[C]: in function 'bee.filesystem.canonical'
script\cli\doc\export.lua:61: in field 'getLocalPath'
script\cli\doc\export.lua:170: in field '?'
script\cli\doc\export.lua:118: in field 'documentObject'
script\cli\doc\export.lua:261: in field 'variable'
script\cli\doc\export.lua:235: in field '?'
script\cli\doc\export.lua:118: in field 'documentObject'
script\cli\doc\export.lua:287: in field 'makeDocs'
script\cli\doc\init.lua:162: in function 'cli.doc.makeDoc'
script\core\command\exportDocument.lua:10: in function 'core.command.exportDocument'
script\provider\provider.lua:1009: in function <script\provider\provider.lua:987>
[C]: in function 'xpcall'
script\proto\proto.lua:202: in function <script\proto\proto.lua:177>
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 script/cli/doc/export.lua 开始,尤其检查第 61 行的 getLocalPath,并在 Lua 项目中通过 VS Code 命令面板导出文档来复现该故障。检查提议的路径回退,并验证文档导出能够在没有 nil-path canonical 错误的情况下完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- lua, vscode
- 领域
- documentation
- Issue 类型
- 缺陷
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 活跃度
- 停滞
- 描述清晰度
- 描述清楚
- 新手友好度
- 55/100