Koihik / LuaFormatter

Code formatter for Lua
Apache License 2.0
708 stars 86 forks source link

Feature request: pad_block #268

Open Josef-Friedrich opened 1 year ago

Josef-Friedrich commented 1 year ago

Some style guidelines require that block statements must begin and end with blank lines. I would apprecitae if this lovely formatter could support this with the help of an option e. g. pad_block.

https://eslint.org/docs/latest/rules/padded-blocks

Function blocks

-- pad_block: true
function outer() 

  local function inner1() 

  end

  local function inner2() 

  end

end

-- pad_block: false
function outer() 
  local function inner1() 

  end

  local function inner2() 

  end
end

Control structure blocks

-- pad_block: true
if x == 1 then 

  print(x)

else

  print(1)

end

-- pad_block: false
if x == 1 then 
  print(x)
else
  print(1)
end

Busted

-- pad_block: true
require('busted.runner')()

describe('Test module', function()

  describe('Test function', function()

    it('My test', function()

      assert.are.equal(1, 1,)

    end)

  end)

end)

-- pad_block: false
require('busted.runner')()
describe('Test module', function()
  describe('Test function', function()
    it('My test', function()
      assert.are.equal(1, 1,)
    end)
  end)
end)