Skip to content

Commit

Permalink
chore: use stylua for formating
Browse files Browse the repository at this point in the history
* Switch to stylua for formating

* Change lua-format ignore to stylua ignore.

* Add workflow for formating with stylua
  • Loading branch information
shadmansaleh authored Sep 3, 2021
1 parent b2fcf50 commit 4042e83
Show file tree
Hide file tree
Showing 41 changed files with 116 additions and 76 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/formating.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: formatting
on:
push:
paths:
- "lua/**.lua"
- "examples/**.lua"
branches: ["master"]

jobs:
stylua:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
STYLUA_VERSION: 0.10.1
steps:
- uses: actions/checkout@v2
- name: Setup git
run: |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
printf 'STYLE_BRANCH=bot/style/%s\n' ${GITHUB_REF#refs/heads/} >> $GITHUB_ENV
- name: Apply stylua
run: |
git checkout -b ${STYLE_BRANCH}
curl -Lo /tmp/stylua.zip https://github.com/JohnnyMorganz/StyLua/releases/download/v${STYLUA_VERSION}/stylua-${STYLUA_VERSION}-linux.zip
unzip -d /tmp/ /tmp/stylua.zip
chmod +x /tmp/stylua
/tmp/stylua --config-path=.stylua.toml lua/ examples/
- name: Create PR
run: |
if ! [[ -z $(git status -s) ]]; then
git add -u
git commit -m "chore: formated with stylua"
git push --force https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY} ${STYLE_BRANCH}
gh pr create --fill --base ${GITHUB_REF#refs/heads/} --head ${STYLE_BRANCH} || true
fi
3 changes: 0 additions & 3 deletions .lua-format

This file was deleted.

4 changes: 4 additions & 0 deletions .stylua.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
indent_type = "Spaces"
indent_width = 2
quote_style = "AutoPreferSingle"
no_call_parentheses = true
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ lint:
@luacheck examples/

format:
@for file in `find . -name '*.lua'`;do lua-format $$file -i; done;
@stylua --config-path=.stylua.toml lua/ examples/

test:
@nvim --headless -u lua/tests/minimal_init.lua -c "PlenaryBustedDirectory lua/tests/ { minimal_init = './lua/tests/minimal_init.lua' }"
Expand Down
3 changes: 1 addition & 2 deletions examples/bubbles.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
-- Author: lokesh-krishna
-- MIT license, see LICENSE for more details.

-- LuaFormatter off
-- stylua: ignore
local colors = {
blue = '#80a0ff',
cyan = '#79dac8',
Expand All @@ -12,7 +12,6 @@ local colors = {
violet = '#d183e8',
grey = '#303030',
}
-- LuaFormatter on

local bubbles_theme = {
normal = {
Expand Down
5 changes: 3 additions & 2 deletions lua/lualine/components/fileformat.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
-- MIT license, see LICENSE for more details.
local FileFormat = require('lualine.component'):new()

-- stylua: ignore
FileFormat.icon = {
unix = '', -- e712
dos = '', -- e70f
mac = '' -- e711
dos = '', -- e70f
mac = '' -- e711
}

FileFormat.update_status = function(self)
Expand Down
4 changes: 2 additions & 2 deletions lua/lualine/themes/16color.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
-- Copyright (c) 2020-2021 shadmansaleh
-- MIT license, see LICENSE for more details.
-- Credit itchyny, jackno (lightline)
-- LuaFormatter off
-- stylua: ignore
local colors = {
black = '#000000',
maroon = '#800000',
Expand All @@ -20,7 +20,7 @@ local colors = {
aqua = '#00ffff',
white = '#ffffff',
}
-- LuaFormatter on

return {
normal = {
a = {fg = colors.white, bg = colors.blue, gui = 'bold'},
Expand Down
4 changes: 2 additions & 2 deletions lua/lualine/themes/OceanicNext.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
-- MIT license, see LICENSE for more details.
-- Genarated by lightline to lualine theme converter
-- https://gist.github.com/shadmansaleh/000871c9a608a012721c6acc6d7a19b9
-- LuaFormatter off
-- stylua: ignore
local colors = {
color0 = '#ffffff',
color1 = '#99c794',
Expand All @@ -13,7 +13,7 @@ local colors = {
color6 = '#f99157',
color7 = '#ec5f67',
}
-- LuaFormatter on

return {
insert = {
a = {fg = colors.color0, bg = colors.color1, gui = 'bold'},
Expand Down
4 changes: 2 additions & 2 deletions lua/lualine/themes/Tomorrow.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
-- MIT license, see LICENSE for more details.
-- Genarated by lightline to lualine theme converter
-- https://gist.github.com/shadmansaleh/000871c9a608a012721c6acc6d7a19b9
-- LuaFormatter off
-- stylua: ignore
local colors = {
color14 = '#718c00',
color0 = '#666666',
Expand All @@ -16,7 +16,7 @@ local colors = {
color8 = '#8959a8',
color11 = '#f5871f',
}
-- LuaFormatter on

return {
inactive = {
a = {fg = colors.color0, bg = colors.color1, gui = 'bold'},
Expand Down
4 changes: 2 additions & 2 deletions lua/lualine/themes/ayu_dark.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
-- MIT license, see LICENSE for more details.
-- Genarated by lightline to lualine theme converter
-- https://gist.github.com/shadmansaleh/000871c9a608a012721c6acc6d7a19b9
-- LuaFormatter off
-- stylua: ignore
local colors = {
color2 = '#0f1419',
color3 = '#ffee99',
Expand All @@ -13,7 +13,7 @@ local colors = {
color8 = '#f07178',
color9 = '#3e4b59',
}
-- LuaFormatter on

return {
visual = {
a = {fg = colors.color2, bg = colors.color3, gui = 'bold'},
Expand Down
4 changes: 2 additions & 2 deletions lua/lualine/themes/ayu_light.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
-- MIT license, see LICENSE for more details.
-- Genarated by lightline to lualine theme converter
-- https://gist.github.com/shadmansaleh/000871c9a608a012721c6acc6d7a19b9
-- LuaFormatter off
-- stylua: ignore
local colors = {
color2 = '#f3f3f3',
color3 = '#A37ACC',
Expand All @@ -13,7 +13,7 @@ local colors = {
color8 = '#f07178',
color9 = '#828C99',
}
-- LuaFormatter on

return {
visual = {
a = {fg = colors.color2, bg = colors.color3, gui = 'bold'},
Expand Down
4 changes: 2 additions & 2 deletions lua/lualine/themes/ayu_mirage.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
-- MIT license, see LICENSE for more details.
-- Genarated by lightline to lualine theme converter
-- https://gist.github.com/shadmansaleh/000871c9a608a012721c6acc6d7a19b9
-- LuaFormatter off
-- stylua: ignore
local colors = {
color2 = '#242b38',
color3 = '#d4bfff',
Expand All @@ -13,7 +13,7 @@ local colors = {
color8 = '#f07178',
color9 = '#607080',
}
-- LuaFormatter on

return {
visual = {
a = {fg = colors.color2, bg = colors.color3, gui = 'bold'},
Expand Down
4 changes: 2 additions & 2 deletions lua/lualine/themes/codedark.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
-- Copyright (c) 2020-2021 Shatur95
-- MIT license, see LICENSE for more details.
-- LuaFormatter off
-- stylua: ignore
local colors = {
gray = '#3C3C3C',
lightred = '#D16969',
Expand All @@ -10,7 +10,7 @@ local colors = {
white = '#D4D4D4',
green = '#608B4E',
}
-- LuaFormatter on

return {
normal = {
b = {fg = colors.green, bg = colors.black},
Expand Down
4 changes: 2 additions & 2 deletions lua/lualine/themes/dracula.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
-- Copyright (c) 2020-2021 shadmansaleh
-- MIT license, see LICENSE for more details.
-- Credit itchyny, jackno (lightline)
-- LuaFormatter off
-- stylua: ignore
local colors = {
gray = '#44475a',
lightgray = '#5f6a8e',
Expand All @@ -13,7 +13,7 @@ local colors = {
white = '#f8f8f2',
black = '#282a36',
}
-- LuaFormatter on

return {
normal = {
a = {bg = colors.purple, fg = colors.black, gui = 'bold'},
Expand Down
4 changes: 2 additions & 2 deletions lua/lualine/themes/everforest.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
-- Copyright (c) 2020-2021 gnuyent
-- MIT license, see LICENSE for more details.
-- LuaFormatter off
-- stylua: ignore
local colors = {
bg0 = '#323d43',
bg1 = '#3c474d',
Expand All @@ -13,7 +13,7 @@ local colors = {
red = '#e68183',
grey1 = '#868d80',
}
-- LuaFormatter on

return {
normal = {
a = {bg = colors.green, fg = colors.bg0, gui = 'bold'},
Expand Down
4 changes: 2 additions & 2 deletions lua/lualine/themes/gruvbox-material.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
-- Copyright (c) 2020-2021 shadmansaleh
-- MIT license, see LICENSE for more details.
-- LuaFormatter off
-- stylua: ignore
local colors = {
fg1 = '#282828',
color2 = '#504945',
Expand All @@ -13,7 +13,7 @@ local colors = {
color8 = '#d3869b',
color9 = '#ea6962',
}
-- LuaFormatter on

return {
normal = {
a = {fg = colors.fg1, bg = colors.color4, gui = 'bold'},
Expand Down
4 changes: 2 additions & 2 deletions lua/lualine/themes/gruvbox_dark.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
-- Copyright (c) 2020-2021 hoob3rt
-- MIT license, see LICENSE for more details.
-- LuaFormatter off
-- stylua: ignore
local colors = {
black = '#282828',
white = '#ebdbb2',
Expand All @@ -13,7 +13,7 @@ local colors = {
lightgray = '#504945',
inactivegray = '#7c6f64',
}
-- LuaFormatter on

return {
normal = {
a = {bg = colors.gray, fg = colors.black, gui = 'bold'},
Expand Down
2 changes: 2 additions & 0 deletions lua/lualine/themes/gruvbox_light.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
-- stylua: ignore
local colors = {
black = '#3c3836',
white = '#f9f5d7',
Expand All @@ -9,6 +10,7 @@ local colors = {
lightgray = '#ebdbb2',
inactivegray = '#a89984'
}

return {
normal = {
a = {bg = colors.darkgray, fg = colors.white, gui = 'bold'},
Expand Down
4 changes: 2 additions & 2 deletions lua/lualine/themes/horizon.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
-- Copyright (c) 2021 Jnhtr
-- MIT license, see LICENSE for more details.
-- LuaFormatter off
-- stylua: ignore
local colors = {
black = '#1c1e26',
white = '#6C6F93',
Expand All @@ -13,7 +13,7 @@ local colors = {
lightgray = '#2E303E',
inactivegray = '#1C1E26',
}
--LuaFormatter on

return {
normal = {
a = {bg = colors.gray, fg = colors.black, gui = 'bold'},
Expand Down
4 changes: 2 additions & 2 deletions lua/lualine/themes/iceberg_dark.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
-- MIT license, see LICENSE for more details.
-- Genarated by lightline to lualine theme converter
-- https://gist.github.com/shadmansaleh/000871c9a608a012721c6acc6d7a19b9
-- LuaFormatter off
-- stylua: ignore
local colors = {
color2 = '#161821',
color3 = '#b4be82',
Expand All @@ -15,7 +15,7 @@ local colors = {
color12 = '#818596',
color15 = '#84a0c6',
}
-- LuaFormatter on

return {
visual = {
a = {fg = colors.color2, bg = colors.color3, gui = 'bold'},
Expand Down
4 changes: 2 additions & 2 deletions lua/lualine/themes/iceberg_light.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
-- MIT license, see LICENSE for more details.
-- Genarated by lightline to lualine theme converter
-- https://gist.github.com/shadmansaleh/000871c9a608a012721c6acc6d7a19b9
-- LuaFormatter off
-- stylua: ignore
local colors = {
color5 = '#668e3d',
color8 = '#757ca3',
Expand All @@ -13,7 +13,7 @@ local colors = {
color1 = '#9fa6c0',
color2 = '#c57339',
}
-- LuaFormatter on

return {
replace = {
b = {fg = colors.color0, bg = colors.color1},
Expand Down
4 changes: 2 additions & 2 deletions lua/lualine/themes/jellybeans.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
-- MIT license, see LICENSE for more details.
-- Genarated by lightline to lualine theme converter
-- https://gist.github.com/shadmansaleh/000871c9a608a012721c6acc6d7a19b9
-- LuaFormatter off
-- stylua: ignore
local colors = {
color2 = '#30302c',
color3 = '#f0a0c0',
Expand All @@ -14,7 +14,7 @@ local colors = {
color11 = '#8197bf',
color14 = '#99ad6a',
}
-- LuaFormatter on

return {
visual = {
a = {fg = colors.color2, bg = colors.color3, gui = 'bold'},
Expand Down
4 changes: 2 additions & 2 deletions lua/lualine/themes/material.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
-- Copyright (c) 2020-2021 shadmansaleh
-- MIT license, see LICENSE for more details.
-- Credit: Lokesh Krishna(lightline)
-- LuaFormatter off
-- stylua: ignore
local colors = {
fg = '#eeffff',
bg = '#263238',
Expand All @@ -15,7 +15,7 @@ local colors = {
gray2 = '#2E3C43',
gray3 = '#515559',
}
-- LuaFormatter on

return {
normal = {
a = {fg = colors.bg, bg = colors.blue, gui = 'bold'},
Expand Down
Loading

0 comments on commit 4042e83

Please sign in to comment.