LuaLS / lua-language-server

A language server that offers Lua language support - programmed in Lua
https://luals.github.io
MIT License
3.38k stars 319 forks source link

How to annotate default arguments to parameters #2959

Open rhys-vdw opened 1 week ago

rhys-vdw commented 1 week ago

Is there a standard way to annotate default arguments? I believe in LDoc you can do:

-- @string[opt='gregorian'] calendar optional calendar
-- @int[opt=0] offset optional offset

I'm currently converting some docs over and couldn't find anything in the wiki.

CppCXY commented 1 week ago

no this feature, to implement this feature, it is necessary to support parsing Lua expressions in the documentation, which might disrupt the existing documentation parsing method.

lewis6991 commented 6 days ago

Some default arguments could be inferred from the body of the function. E.g. for lines like opts = opts or {}, or timeout = timeout or 300.

rhys-vdw commented 6 days ago

In my case I'm trying to generate them for C code, but I've just resolved to include the default in the comment for now.