LuaLS / LuaLS/lua-language-server
[Question/Request] Can I recycle common params for differing functions without mass copy+paste?
Nobody has claimed this yet.
- Dominant language
- Lua
- Stars
- 4.4k
- Forks
- 442
- PR merge metrics
- No merged PRs in 30d
Description
I would like to be able to recycle a list of parameters (and types), sometimes with an extra parameter or a different set of return values. I only know how to do this via copy+paste of parameters from one function to the next, and edit as needed. However, I am trying to reduce the code volume, clarity, as well as make it easier to enact changes that should cascade to any function which uses those sets of parameters.
Here's an example:
---@param blah number
---@param barf function
---@param puke fun(boolean):number
---@param thanks table
function foo(blah, barf, puke, thanks)
end
---@param blah number
---@param barf function
---@param puke fun(boolean):number
---@param thanks table
---@return boolean
function bar(blah, barf, puke, thanks)
return true
end
I'd like to be able to define a 'defined parameter set' which would allow me to do something like this:
---@parameters hmmm
---@param blah number
---@param barf function
---@param puke fun(boolean):number
---@param thanks table
---@uses parameters hmmm
function foo(blah, barf, puke, thanks)
end
---@uses parameters hmmm
---@return boolean
function bar(blah, barf, puke, thanks)
return true
end
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
The issue names no implementation files, tests, or entry points. Start by locating how Lua annotations such as @param and @return are parsed, then assess how a reusable parameter-set declaration and its use would fit that syntax. Done means shared parameters can be documented once, reused by multiple functions, extended or combined with differing return values, 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