LuaLS / lua-language-server

A language server that offers Lua language support - programmed in Lua
https://luals.github.io
MIT License
3.35k stars 320 forks source link

Remove continuous empty lines #1687

Open ab22593k opened 1 year ago

ab22593k commented 1 year ago

How are you using the lua-language-server?

Visual Studio Code Extension (sumneko.lua)

Which OS are you using?

Linux

What is the issue affecting?

Formatting

Expected Behaviour

continuous empty lines should be removed

Actual Behaviour

nothing happen?

Reproduction steps

  1. Go to lua source file
  2. Add continuous empty lines
  3. Click save to Format the code

Additional Notes

I have the following vscode setting.json file:

{
    "Lua.format.defaultConfig": {
        "indent_style": "tab",
        "indent_size": "4",
        "max_line_length": "80",
        "max_continuous_line_distance": "1",
    },
}

Log File

[21:31:44.449][info] [#0:/home/wahabz/.vscode/extensions/sumneko.lua-3.6.2-linux-x64/server/main.lua:65]: Lua Lsp startup, root: /home/wahabz/.vscode/extensions/sumneko.lua-3.6.2-linux-x64/server [21:31:44.450][info] [#0:/home/wahabz/.vscode/extensions/sumneko.lua-3.6.2-linux-x64/server/main.lua:66]: ROOT: /home/wahabz/.vscode/extensions/sumneko.lua-3.6.2-linux-x64/server [21:31:44.450][info] [#0:/home/wahabz/.vscode/extensions/sumneko.lua-3.6.2-linux-x64/server/main.lua:67]: LOGPATH: /home/wahabz/.vscode/extensions/sumneko.lua-3.6.2-linux-x64/server/log [21:31:44.450][info] [#0:/home/wahabz/.vscode/extensions/sumneko.lua-3.6.2-linux-x64/server/main.lua:68]: METAPATH: /home/wahabz/.vscode/extensions/sumneko.lua-3.6.2-linux-x64/server/meta [21:31:44.450][info] [#0:/home/wahabz/.vscode/extensions/sumneko.lua-3.6.2-linux-x64/server/main.lua:69]: VERSION: 3.6.2 [21:31:44.520][info] [#0:script/service/service.lua:141]: ========= Medical Examination Report ========= --------------- Memory --------------- Total: 1.545 MB

00 : 1.545 MB

01 : 0.000 MB

02 : 0.000 MB

03 : 0.000 MB

04 : 0.000 MB

--------------- Coroutine --------------- Total: 0 Running: 0 Suspended: 0 Normal: 0 Dead: 0 --------------- Cache --------------- Total: 1 Dead: 0 --------------- RPC --------------- Holdon: 0 Waiting: 0

[21:31:44.531][info] [#0:script/language.lua:137]: VSC language: en-us [21:31:44.531][info] [#0:script/language.lua:138]: LS language: en-us

sumneko commented 1 year ago

@CppCXY

CppCXY commented 1 year ago

because of my bad option name, you may have misunderstood. remove empty lines of a statement requires a set of options

keep_line_after_if_statement = maxLine:1
keep_line_after_do_statement = maxLine:1
keep_line_after_while_statement = maxLine:1
keep_line_after_repeat_statement = maxLine:1
keep_line_after_for_statement = maxLine:1
keep_line_after_local_or_assign_statement = maxLine:1
keep_line_after_function_define_statement = keepLine:1
keep_line_after_expression_statement = maxLine:1
sumneko commented 1 year ago

By the way, can it supports keep_line_after_* = maxLine:1 ?

CppCXY commented 1 year ago

good idea, after refactor, I will try