LuaLS / LuaLS/lua-language-server
Undefined global: vim, hs, mp, anything implicitly defined by a parent
还没有人认领这个 Issue。
- 主要语言
- Lua
- 星标
- 4.4k
- 派生
- 442
- PR 合并指标
- 30 天内没有已合并 PR
描述
How are you using the lua-language-server?
NeoVim
Which OS are you using?
MacOS
What is the issue affecting?
Diagnostics/Syntax Checking
Expected Behaviour
LuaLS should have an annotation to assume a global is already defined. I looked in the documentation and didn't see one, but correct me if I'm wrong.
Actual Behaviour
In Neovim, vim is defined as a global in the Lua init file, which LuaLS complains about. This is frequently worked around by adding it as a global setting to LuaLS, but imo this is a monkey patch because non-Neovim Lua code may benefit from a diagnostic for a missing vim global.
It also doesn't help for other programs that embed Lua and define their own globals. HammerSpoon defines hs and mpv defines mp. In these cases the diagnostic can be circumvented with a require but it's not idiomatic in these domains and doesn't work for Neovim.
Reproduction steps
- Edit NeoVim, HammerSpoon, or mpv script
- Add
vim,hs, ormpto the respective script - Run LuaLS on the script
Additional Notes
No response
Log File
No response
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
未指定源文件或测试。首先跟踪 LuaLS 诊断和现有的全局设置配置,然后确定应如何声明由父级提供的全局变量;当能够识别 Neovim、Hammerspoon 和 mpv 的全局变量,同时不抑制与无关名称相关的 undefined-global 诊断时,即表示完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- lua
- 领域
- devtools
- Issue 类型
- 功能
- 难度
- 5/5
- 预计耗时
- 一周以上
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100