LuaFormatter
LuaFormatter copied to clipboard
[question] Keep new line between comments
Hello :)
I wanted to ask how could I keep breaks between comments? Example of what I would like to achieve:
--- Main module of the project
-- @module main
--- My function doc
-- @return some value
How the formatter works at the moment:
--- Main module of the project
-- @module main
--- My function doc
-- @return some value
Would you be so kind and tell me can I keep the spaces between comments? Thanks :)
I have the same problem.
I can see line_breaks_after_function_body in Style-Config.md, but that does not preserve spaces between comments and comments or between comments and other code.
No fix on this?
Apart from its otherwise excellent formatting (I tried quite a few others, thanks a lot, Koihik!), this has bugged me, too.
Attached is a patch that tries to solve this issue by analyzing WS after comments, so that the following snippet retains empty lines between comments:
--[[
Copyright ...
]]
--[[
Package description...
]]
-- TODO list
-- - ...
if true --[[ temporarily commented out condition ]] then
-- do something
end
I have to note, though, that the inlined "long comments" do fail if the line is too long (and causes the lua-formatter-test to fail for one case). On the other hand, code-writers do not have to write comments with work-arounds as described in https://github.com/Koihik/LuaFormatter/issues/32.
Indeed.
As soon as LuaFormatter keeps SPDX statements functional (i. e. this issue is fixed), I will use it in my CI pipelines.