Yuescript icon indicating copy to clipboard operation
Yuescript copied to clipboard

Preserve comments preceding global declarations

Open Seirdy opened this issue 1 year ago • 5 comments

Existing issues, such as #58 and #57, have requested support for static type annotations. A less extreme solution would be to preserve comments containing Sumneko's annotations for use with their Lua language server. This way, the resulting Lua code will be identical but still support type-checking. It could also improve interoperability with other documentation generators.

The Yuescript tool could expose an option to preserve comments directly before global declarations, e.g. those displayed by yue -g

Seirdy avatar Feb 26 '23 18:02 Seirdy

added option yue -c to reserve some comments before statements, like

---@param a any
---@param b any
---@param c any
f = (a, b, c)->

But not sure if this works for the Lua LSP functions.

pigpigyyy avatar Feb 27 '23 04:02 pigpigyyy

I have custom script that use yue module to compile to lua. Can you make 'reserve_comment' support in yue module!

Thanks and regards!

GokuHiki avatar Feb 28 '23 07:02 GokuHiki

'reserve_comment' was added in module. Should be available as

local yue = require("yue")
print yue.to_lua([[
-- a comment
f = ->
]], {reserve_comment = true})

pigpigyyy avatar Mar 05 '23 01:03 pigpigyyy

Shouldn't it be preserve_comment (with a p in the beginning)?

SkyyySi avatar May 17 '23 14:05 SkyyySi

"preserve" and "reserve" both have the meaning of keeping something, while "reserve" is just for keeping something for future use, the "preserve" word has more meaning of keeping something from harm (protect). So I think using the "reserve" word could be better.

pigpigyyy avatar May 17 '23 15:05 pigpigyyy