You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Lua has a named arguments pattern where you pass all the named arguments inside a table. This can be supported in LuaLS by declaring a class for the arguments table:
---@classFooArgs---@fieldbarnumber The `bar` argument---@fieldbazstring The `baz` argument---@fieldquxboolean The `qux` argument---The `foo` function---@paramargsFooArgs Named argumentslocalfunctionfoo(args)
-- ...end
And it gives you completion, linting, and hover docs for the fields:
But the hover for the function itself only shows the opaque type:
If would be nice if, instead, we could have something like this:
functionfoo(args: FooArgs)
─────────────────────────────────
The foo function
@paramargs — Named arguments:
bar: number — The bar argument
baz: string — The baz argument
qux: boolean — The qux argument
This will also look nicer in the generated docs.
Of course, this should not be the default behavior. I'm thinking of two options for this syntax:
A modifier to ---@param:
---The `foo` function---@param (inline) args FooArgs Named argumentslocalfunctionfoo(args)
-- ...end
Specifying the "paths" of the table fields:
---The `foo` function---@paramargsFooArgs Named arguments---@paramargs.bar number The `bar` argument---@paramargs.baz string The `baz` argument---@paramargs.qux boolean The `qux` argumentlocalfunctionfoo(args)
-- ...end
I think you can enable inlay hint ("Lua.hint.enable": true)
That way when you are calling the function, you can see the param name, and its hover docs should be what you want.
Another useful extension setting is to show param name only when it's literal ("Lua.hint.paramName": "Literal")
Such that the inline hint will not be too distracting 😃
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Lua has a named arguments pattern where you pass all the named arguments inside a table. This can be supported in LuaLS by declaring a class for the arguments table:
And it gives you completion, linting, and hover docs for the fields:
But the hover for the function itself only shows the opaque type:
If would be nice if, instead, we could have something like this:
This will also look nicer in the generated docs.
Of course, this should not be the default behavior. I'm thinking of two options for this syntax:
---@param:All reactions