lua-language-server
lua-language-server copied to clipboard
Separate vararg from type if given
v3.4.2
Given the following function declaration/annotation:
---Write output to the console
---@param severity loggingSeverity
---@param message number|string|table|nil A message to display to the console; can contain formatting directives for further parameters
---@vararg any
function SmallNote.Write(severity, message, ...)
if (severity == 'trace') then
print("Trace: ", string.format(message, ...))
end
end
the annotation for the vararg displays with the ...
right up against the specified type.
I think this should display as ...: any
.
This was actually an intentional choice because it distinguishes ...
from named parameters and is visually similar to how many strongly-typed languages handle variadic arguments in their function declarations (see #1207). Disclaimer: I am one of the people who suggested ...typename
to replace ...: typename
.
Maybe a setting?
I think ...any
looks more beautiful than ...: any
From an aesthetics perspective, I disagree. ...any
just runs on together and I have to stop (if only briefly) to process it. At first take, my mind just runs on past it initially. It's also inconsistent with the formatting of the other parameters.
If that's your design decision, I can live with it (even if it's not my preference). A toggle setting satisfies both sides, but I recognize it puts an additional maintenance burden on you (for something you don't believe is necessary).
Since it's just a matter of personal preference, I'm not going to change it again. But I don't mind there is a PR to implement a toggle setting.
Closing stale issue