Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preserve comments preceding global declarations #126

Open
Seirdy opened this issue Feb 26, 2023 · 5 comments
Open

Preserve comments preceding global declarations #126

Seirdy opened this issue Feb 26, 2023 · 5 comments

Comments

@Seirdy
Copy link

Seirdy commented Feb 26, 2023

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 Seirdy changed the title Preserve some comments Preserve comments preceding global declarations Feb 26, 2023
@pigpigyyy
Copy link
Owner

pigpigyyy commented Feb 27, 2023

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.

@GokuHiki
Copy link

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

Thanks and regards!

pigpigyyy added a commit that referenced this issue Mar 2, 2023
@pigpigyyy
Copy link
Owner

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

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

@SkyyySi
Copy link

SkyyySi commented May 17, 2023

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

@pigpigyyy
Copy link
Owner

pigpigyyy commented May 17, 2023

"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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants