LuaFormatter icon indicating copy to clipboard operation
LuaFormatter copied to clipboard

[question] Keep new line between comments

Open rafauke opened this issue 4 years ago • 4 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 :)

rafauke avatar Dec 01 '20 10:12 rafauke

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.

doxygen-spammer avatar Sep 20 '21 19:09 doxygen-spammer

No fix on this?

pinguluk avatar Mar 14 '23 19:03 pinguluk

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.

fromsawa avatar Apr 02 '23 11:04 fromsawa

Indeed.

As soon as LuaFormatter keeps SPDX statements functional (i. e. this issue is fixed), I will use it in my CI pipelines.

doxygen-spammer avatar Apr 02 '23 17:04 doxygen-spammer