CppCXY / EmmyLuaCodeStyle

fast, powerful, and feature-rich Lua formatting and checking tool.
MIT License
139 stars 27 forks source link

end_statement_with_semicolon, line break after every statement #163

Closed po0p closed 8 months ago

po0p commented 8 months ago

Hi, Sorry if this sounds funny, this is my 2nd month of working with lua. I am using EmmyLua as a part of sumneko.lua vscode extension. I have a question possibly about this option, and possibly about other one (which doesnt seem to exist).

It could be described like line breaks after statement = min(1), i.e. i want to get rid of continious statements on one-line. end_statement_with_semicolon = replace_with_newline achieves what i need, but what if i also wanted to keep the semicolon?

I.e.: local a = 1; local b = 2; local c = "missing_semicolon" local d = 1337; to get formatted as:

local a = 1;
local b = 2;
local c = "semicolon";
local d = 1337;

It works like this in github.com/Koihik/LuaFormatter, im just not sure what option controls that, but default formatting keeps the semicolon if it exists AND also breaks continious statements with newlines.

Attaching a video, maybe it will be easier to understand.

https://github.com/CppCXY/EmmyLuaCodeStyle/assets/68482185/1758487e-4d55-460f-8054-e99126f30f12

Thanks a lot, your formatter is great!

CppCXY commented 8 months ago

that's how it's designed, because the semicolon isn't normally used in lua, so if a statement ends with a semicolon, it's probably for the purpose of

local t; do
    t = 123
end

or

local v; init(v)

this suggestion comes from #102

my formatter respects the original formatting as much as possible, so I suggest that if you wish to keep the semicolon then you can manually break the line.

po0p commented 8 months ago

my formatter respects the original formatting as much as possible, so I suggest that if you wish to keep the semicolon then you can manually break the line. I see, I also assume that something like one-line-simple-functions / -simple-statemenets is not what you would want to do? i.e. if a=b then print(c) end or local function d(...) print(tostring(...)) end to be line broken into normal identation?

CppCXY commented 8 months ago

If it was on the same line, then it will stay on the same line after formatting, if it is not on the same line, then it will not collapse to the same line.

po0p commented 8 months ago

Thanks for the explanation!