LuaLS / LuaLS/lua-language-server
`module()` function isn't respected by the language server
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?
Visual Studio Code Extension (sumneko.lua)
### Which OS are you using?
Linux
### What is the issue affecting?
Diagnostics/Syntax Checking
### Expected Behaviour
When `module()` is used in a script, functions defined "globally", like so:
```lua
module("MyExampleModule")
function HelloWorld() end
```
Are understood by the language server to belong to the table at `_G.MyExampleModule`
### Actual Behaviour
Using the above example, the language server incorrectly believes `HelloWorld()` is at `_G.HelloWorld()` as opposed to `_G.MyExampleModule.HelloWorld()`
### Reproduction steps
1. Copy the above example into a file
2. Create another file in the same workspace
3. Type "Hello"
4. Observe that the autocomplete suggests the function `_G.HelloWorld()`, which does not exist
### Additional Notes
This cannot be worked around with `setfenv()`
### Log File
N/A
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
Reproduce the issue in the Visual Studio Code extension using the two-file example and the autocomplete step described. Trace how module("MyExampleModule") is handled during diagnostics and completion, then verify that HelloWorld is suggested under _G.MyExampleModule rather than _G.HelloWorld.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- lua
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100