LuaLS / LuaLS/lua-language-server
Undefined global: vim, hs, mp, anything implicitly defined by a parent
Nobody has claimed this yet.
- Dominant language
- Lua
- Stars
- 4.4k
- Forks
- 442
- PR merge metrics
- No merged PRs in 30d
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No source files or tests are named. Start by tracing LuaLS diagnostics and the existing global-setting configuration, then determine how parent-provided globals should be declared; done means Neovim, Hammerspoon, and mpv globals can be recognized without suppressing undefined-global diagnostics for unrelated names.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- lua
- Domain
- devtools
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100