LuaLS / LuaLS/lua-language-server
Auto-complete for table keys with @type breaks on non-locals
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?
Windows
What is the issue affecting?
Completion
Expected Behaviour
Using ---@type table<KeyType, ValueType> on a table should always keep auto-complete available for keys within the table.
Actual Behaviour
Auto-complete breaks if the table that ---@type was used on is global or within a class.
Reproduction steps
Scenario where auto-complete works:
---@class MyClass
---@field MyThings any
---@type table<string, MyClass>
local SomeTable = {
SomeKey = {MyField = 1},
SomeKey2 = {MyField = 1},
}
Scenario where auto-complete does not work:
---@class MyClass
---@field MyThings any
---@type table<string, MyClass>
SomeTable = {
SomeKey = {MyField = 1},
SomeKey2 = {MyField = 1},
}
No auto-complete will be available for SomeTable there. This also occurs if SomeTable is within a table marked with ---@class.
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
Reproduce the two table-key completion scenarios in the Visual Studio Code extension, comparing local, global, and class-contained tables annotated with table<KeyType, ValueType>. Trace the completion handling for these annotations and verify that key completion remains available in each scenario.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- lua
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100