LuaLS / LuaLS/lua-language-server
Feature Request/How-to: Inlined parameter annotation
Open
Nobody has claimed this yet.
enhancement
- Dominant language
- Lua
- Stars
- 4.4k
- Forks
- 442
- PR merge metrics
- No merged PRs in 30d
Description
I'd like to be able to do inlined type annotation for parameters. It doesn't currently seem to be possible. What I mean is, instead of this:
---@param key unknown
---@param callbackFn fun(Hook, ...):any
---@param priority? number
---@param hostTableToHook? table
---@param defaultNativeBehavior? function
---@param hookedTableIsMetaTable? boolean
function Hook.basic(key, callbackFn, priority, hostTableToHook, defaultNativeBehavior, hookedTableIsMetaTable)
return Hook.add(key, callbackFn, priority, hostTableToHook, defaultNativeBehavior, hookedTableIsMetaTable, true)
end
I'd like to be able to do this:
function Hook.basic(
key, ---@param unknown
callbackFn, ---@param fun(Hook, ...):any
priority, ---@param? number
hostTableToHook, ---@param? table
defaultNativeBehavior, ---@param? function
hookedTableIsMetaTable ---@param? boolean
)
return Hook.add(key, callbackFn, priority, hostTableToHook, defaultNativeBehavior, hookedTableIsMetaTable, true)
end
This would cut down on the boilerplate a bit and make the code cleaner.
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 locating the language server's parsing and tests for function parameters and existing inline annotations. Compare those paths with the two syntax examples in this issue; done means inline parameter annotations are accepted, interpreted with the shown optional and function types, and covered by tests.
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
- 25/100