LuaLS / LuaLS/lua-language-server
Doc export format requirements break auto-completion, and vice-versa
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?
MacOS
What is the issue affecting?
Annotations, Completion, Hover, Other
Expected Behaviour
The format LLS expects to export documentation and handle autocompletion & hover should be the same. I'd like to export documentation from the same set of definition files I'm shipping as an Addon, and keeping them synced to the same source of truth seems the sensible way to go.
Actual Behaviour
This example is valid as far as documentation export, in that the JSON file generated as output contains references to the functions defined. However, this breaks tooltips/popovers/autocompletion, which require testLib to be defined and returned from this module to function:
---@meta cradle.basic.text
---This is test function 1.
---@param a number This is a number.
---@param b number This is another number.
---@return number This is the sum of a and b.
function testLib.add(a, b) end
---This is test function 2.
---@param a number This is a number.
---@param b number This is another number.
---@return number This is the difference of a and b.
function testLib.sub(a, b) end
Conversely, this other example allows tooltips/popovers/autocompletion to function properly, documentation generated via CLI seems to succeed with no errors, however the actual JSON containing the references is missing any reference to testLib entirely:
---@meta cradle.basic.text
local testLib = {}
---This is test function 1.
---@param a number This is a number.
---@param b number This is another number.
---@return number This is the sum of a and b.
function testLib.add(a, b) end
---This is test function 2.
---@param a number This is a number.
---@param b number This is another number.
---@return number This is the difference of a and b.
function testLib.sub(a, b) end
return testLib
Reproduction steps
- Save each of the two examples above as a Lua file somewhere
- Modify LLS config to include them
- Export documentation via CLI and try to require the library in the workspace
- Observe that depending on the example tested, either documentation exporting silently fails, or popovers don't work anymore
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
Start by reproducing the behavior with the two Lua examples in the issue: export documentation through the CLI, then require each library in a workspace and compare completion, hover, and generated JSON references. Trace the differing handling of module-level definitions and returned tables; done means one source format supports both documentation export and editor features without silently losing testLib.
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
- Mostly clear
- Newbie friendliness
- 35/100