chore: use stylua for formating

* Switch to stylua for formating

* Change lua-format ignore to stylua ignore.

* Add workflow for formating with stylua
This commit is contained in:
Shadman 2021-09-04 00:20:34 +06:00 committed by GitHub
parent b2fcf50742
commit 4042e837f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
41 changed files with 116 additions and 76 deletions

39
.github/workflows/formating.yml vendored Normal file
View File

@ -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

View File

@ -1,3 +0,0 @@
indent_width: 2
continuation_indent_with: 2
double_quote_to_single_quote: true

4
.stylua.toml Normal file
View File

@ -0,0 +1,4 @@
indent_type = "Spaces"
indent_width = 2
quote_style = "AutoPreferSingle"
no_call_parentheses = true

View File

@ -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' }"

View File

@ -2,7 +2,7 @@
-- Author: lokesh-krishna
-- MIT license, see LICENSE for more details.
-- LuaFormatter off
-- stylua: ignore
local colors = {
blue = '#80a0ff',
cyan = '#79dac8',
@ -12,7 +12,6 @@ local colors = {
violet = '#d183e8',
grey = '#303030',
}
-- LuaFormatter on
local bubbles_theme = {
normal = {

View File

@ -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)

View File

@ -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',
@ -20,7 +20,7 @@ local colors = {
aqua = '#00ffff',
white = '#ffffff',
}
-- LuaFormatter on
return {
normal = {
a = {fg = colors.white, bg = colors.blue, gui = 'bold'},

View File

@ -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',
@ -13,7 +13,7 @@ local colors = {
color6 = '#f99157',
color7 = '#ec5f67',
}
-- LuaFormatter on
return {
insert = {
a = {fg = colors.color0, bg = colors.color1, gui = 'bold'},

View File

@ -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',
@ -16,7 +16,7 @@ local colors = {
color8 = '#8959a8',
color11 = '#f5871f',
}
-- LuaFormatter on
return {
inactive = {
a = {fg = colors.color0, bg = colors.color1, gui = 'bold'},

View File

@ -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',
@ -13,7 +13,7 @@ local colors = {
color8 = '#f07178',
color9 = '#3e4b59',
}
-- LuaFormatter on
return {
visual = {
a = {fg = colors.color2, bg = colors.color3, gui = 'bold'},

View File

@ -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',
@ -13,7 +13,7 @@ local colors = {
color8 = '#f07178',
color9 = '#828C99',
}
-- LuaFormatter on
return {
visual = {
a = {fg = colors.color2, bg = colors.color3, gui = 'bold'},

View File

@ -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',
@ -13,7 +13,7 @@ local colors = {
color8 = '#f07178',
color9 = '#607080',
}
-- LuaFormatter on
return {
visual = {
a = {fg = colors.color2, bg = colors.color3, gui = 'bold'},

View File

@ -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',
@ -10,7 +10,7 @@ local colors = {
white = '#D4D4D4',
green = '#608B4E',
}
-- LuaFormatter on
return {
normal = {
b = {fg = colors.green, bg = colors.black},

View File

@ -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',
@ -13,7 +13,7 @@ local colors = {
white = '#f8f8f2',
black = '#282a36',
}
-- LuaFormatter on
return {
normal = {
a = {bg = colors.purple, fg = colors.black, gui = 'bold'},

View File

@ -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',
@ -13,7 +13,7 @@ local colors = {
red = '#e68183',
grey1 = '#868d80',
}
-- LuaFormatter on
return {
normal = {
a = {bg = colors.green, fg = colors.bg0, gui = 'bold'},

View File

@ -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',
@ -13,7 +13,7 @@ local colors = {
color8 = '#d3869b',
color9 = '#ea6962',
}
-- LuaFormatter on
return {
normal = {
a = {fg = colors.fg1, bg = colors.color4, gui = 'bold'},

View File

@ -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',
@ -13,7 +13,7 @@ local colors = {
lightgray = '#504945',
inactivegray = '#7c6f64',
}
-- LuaFormatter on
return {
normal = {
a = {bg = colors.gray, fg = colors.black, gui = 'bold'},

View File

@ -1,3 +1,4 @@
-- stylua: ignore
local colors = {
black = '#3c3836',
white = '#f9f5d7',
@ -9,6 +10,7 @@ local colors = {
lightgray = '#ebdbb2',
inactivegray = '#a89984'
}
return {
normal = {
a = {bg = colors.darkgray, fg = colors.white, gui = 'bold'},

View File

@ -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',
@ -13,7 +13,7 @@ local colors = {
lightgray = '#2E303E',
inactivegray = '#1C1E26',
}
--LuaFormatter on
return {
normal = {
a = {bg = colors.gray, fg = colors.black, gui = 'bold'},

View File

@ -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',
@ -15,7 +15,7 @@ local colors = {
color12 = '#818596',
color15 = '#84a0c6',
}
-- LuaFormatter on
return {
visual = {
a = {fg = colors.color2, bg = colors.color3, gui = 'bold'},

View File

@ -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',
@ -13,7 +13,7 @@ local colors = {
color1 = '#9fa6c0',
color2 = '#c57339',
}
-- LuaFormatter on
return {
replace = {
b = {fg = colors.color0, bg = colors.color1},

View File

@ -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',
@ -14,7 +14,7 @@ local colors = {
color11 = '#8197bf',
color14 = '#99ad6a',
}
-- LuaFormatter on
return {
visual = {
a = {fg = colors.color2, bg = colors.color3, gui = 'bold'},

View File

@ -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',
@ -15,7 +15,7 @@ local colors = {
gray2 = '#2E3C43',
gray3 = '#515559',
}
-- LuaFormatter on
return {
normal = {
a = {fg = colors.bg, bg = colors.blue, gui = 'bold'},

View File

@ -1,6 +1,6 @@
-- Copyright (c) 2020-2021 ronniedroid
-- MIT license, see LICENSE for more details.
-- LuaFormatter off
-- stylua: ignore
local colors = {
black = '#000000',
white = '#eeeeee',
@ -13,7 +13,7 @@ local colors = {
darkgray = '#202020',
lightgray = '#434343'
}
-- LuaFormatter on
return {
normal = {
a = {bg = colors.blue, fg = colors.lightgray, gui = 'bold'},

View File

@ -1,7 +1,7 @@
-- Copyright (c) 2020-2021 shadmansaleh
-- MIT license, see LICENSE for more details.
-- Credit: challsted(lightline)
-- LuaFormatter off
-- stylua: ignore
local colors = {
black = '#232526',
gray = '#808080',
@ -13,7 +13,7 @@ local colors = {
red = '#ff0000',
yellow = '#e6db74',
}
-- LuaFormatter on
return {
normal = {
a = {fg = colors.black, bg = colors.cyan, gui = 'bold'},

View File

@ -3,7 +3,7 @@
-- URL: github.com/bluz71/vim-moonfly-colors
-- License: MIT (https://opensource.org/licenses/MIT)
-- LuaFormatter off
-- stylua: ignore
local colors = {
color3 = '#303030',
color6 = '#9e9e9e',
@ -14,7 +14,6 @@ local colors = {
color2 = '#c6c6c6',
}
-- LuaFormatter on
return {
replace = {
a = {fg = colors.color0, bg = colors.color1, gui = 'bold'},

View File

@ -1,6 +1,6 @@
-- Copyright (c) 2020-2021 shadmansaleh
-- MIT license, see LICENSE for more details.
-- LuaFormatter off
-- stylua: ignore
local colors = {
color3 = '#2c3043',
color6 = '#a1aab8',
@ -10,7 +10,7 @@ local colors = {
color1 = '#ff5874',
color2 = '#c3ccdc',
}
-- LuaFormatter on
return {
replace = {
a = {fg = colors.color0, bg = colors.color1, gui = 'bold'},

View File

@ -1,6 +1,6 @@
-- Copyright (c) 2020-2021 shadmansaleh
-- MIT license, see LICENSE for more details.
-- LuaFormatter off
-- stylua: ignore
local colors = {
nord1 = '#3B4252',
nord3 = '#4C566A',
@ -10,7 +10,7 @@ local colors = {
nord8 = '#88C0D0',
nord13 = '#EBCB8B',
}
-- LuaFormatter on
return {
normal = {
a = {fg = colors.nord1, bg = colors.nord8, gui = 'bold'},

View File

@ -1,7 +1,7 @@
-- Copyright (c) 2020-2021 shadmansaleh
-- MIT license, see LICENSE for more details.
-- Credit: Zoltan Dalmadi(lightline)
-- LuaFormatter off
-- stylua: ignore
local colors = {
blue = '#61afef',
green = '#98c379',
@ -15,7 +15,7 @@ local colors = {
gray2 = '#2c323d',
gray3 = '#3e4452',
}
-- LuaFormatter on
return {
normal = {
a = {fg = colors.bg, bg = colors.green, gui = 'bold'},

View File

@ -1,7 +1,7 @@
-- Copyright (c) 2020-2021 shadmansaleh
-- MIT license, see LICENSE for more details.
-- Credit: Zoltan Dalmadi(lightline)
-- LuaFormatter off
-- stylua: ignore
local colors = {
blue = '#61afef',
green = '#98c379',
@ -15,7 +15,7 @@ local colors = {
gray2 = '#f0f0f0',
gray3 = '#d0d0d0',
}
-- LuaFormatter on
return {
normal = {
a = {fg = colors.bg, bg = colors.green, gui = 'bold'},

View File

@ -1,6 +1,6 @@
-- Copyright (c) 2020-2021 IGI-111
-- MIT license, see LICENSE for more details.
-- LuaFormatter off
-- stylua: ignore
local colors = {
vertsplit = '#181A1F',
special_grey = '#3B4048',
@ -20,7 +20,7 @@ local colors = {
comment_grey = '#697098',
black = '#292D3E',
}
-- LuaFormatter on
return {
normal = {
a = {fg = colors.black, bg = colors.purple, gui = 'bold'},

View File

@ -1,7 +1,7 @@
-- Copyright (c) 2020-2021 shadmansaleh
-- MIT license, see LICENSE for more details.
-- Credit: TKNGUE(lightline)
-- LuaFormatter off
-- stylua: ignore
local colors = {
red = '#df0000',
green = '#008700',
@ -24,7 +24,7 @@ local colors = {
visual_fg = '#000000',
visual_bg = '#8787af',
}
-- LuaFormatter on
return {
normal = {
a = {fg = colors.foreground, bg = colors.background, gui = 'bold'},

View File

@ -1,7 +1,7 @@
-- Copyright (c) 2020-2021 shadmansaleh
-- MIT license, see LICENSE for more details.
-- Credit: TKNGUE(lightline)
-- LuaFormatter off
-- stylua: ignore
local colors = {
red = '#df0000',
green = '#008700',
@ -22,7 +22,6 @@ local colors = {
statusline_inactive_fg = '#4d4d4c',
statusline_inactive_bg = '#dadada',
}
-- LuaFormatter on
return {
normal = {

View File

@ -1,6 +1,6 @@
-- Copyright (c) 2020-2021 shadmansaleh
-- MIT license, see LICENSE for more details.
-- LuaFormatter off
-- stylua: ignore
local Colors = {
white = '#ffffff',
darkestgreen = '#005f00',
@ -18,7 +18,7 @@ local Colors = {
gray7 = '#9e9e9e',
gray10 = '#f0f0f0',
}
-- LuaFormatter on
return {
normal = {
a = {fg = Colors.darkestgreen, bg = Colors.brightgreen, gui = 'bold'},

View File

@ -1,6 +1,6 @@
-- Copyright (c) 2021 Ashish Panigrahi
-- MIT license, see LICENSE for more details.
-- LuaFormatter off
-- stylua: ignore
local colors = {
black = '#202020',
neon = '#DFFF00',
@ -21,7 +21,7 @@ local colors = {
brightred = '#AF0000',
cyan = '#00DFFF',
}
-- LuaFormatter on
return {
normal = {
a = {bg = colors.neon, fg = colors.black, gui = 'bold'},

View File

@ -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 = '#d7afaf',
color6 = '#666656',
@ -14,7 +14,7 @@ local colors = {
color1 = '#4e4e43',
color4 = '#30302c',
}
-- LuaFormatter on
return {
visual = {
b = {fg = colors.color0, bg = colors.color1},

View File

@ -1,7 +1,7 @@
-- Copyright (c) 2020-2021 shadmansaleh
-- MIT license, see LICENSE for more details.
-- Credit: itchyny(lightline)
-- LuaFormatter off
-- stylua: ignore
local colors = {
base03 = '#002b36',
base02 = '#073642',
@ -20,7 +20,7 @@ local colors = {
cyan = '#2aa198',
green = '#859900',
}
-- LuaFormatter on
return {
normal = {
a = {fg = colors.base03, bg = colors.blue, gui = 'bold'},

View File

@ -1,7 +1,7 @@
-- Copyright (c) 2020-2021 shadmansaleh
-- MIT license, see LICENSE for more details.
-- Credit: itchyny(lightline)
-- LuaFormatter off
-- stylua: ignore
local colors = {
base3 = '#002b36',
base2 = '#073642',
@ -20,7 +20,7 @@ local colors = {
cyan = '#2aa198',
green = '#859900',
}
-- LuaFormatter on
return {
normal = {
a = {fg = colors.base03, bg = colors.blue, gui = 'bold'},

View File

@ -1,7 +1,7 @@
-- Copyright (c) 2020-2021 shadmansaleh
-- MIT license, see LICENSE for more details.
-- Credit: itchyny(lightline)
-- LuaFormatter off
-- stylua: ignore
local colors = {
base03 = '#242424',
base023 = '#353535',
@ -20,7 +20,7 @@ local colors = {
cyan = '#8ac6f2',
green = '#95e454',
}
-- LuaFormatter on
return {
normal = {
a = {fg = colors.base02, bg = colors.blue, gui = 'bold'},

View File

@ -2,7 +2,7 @@
-- MIT license, see LICENSE for more details.
local M = {}
-- LuaFormatter off
-- stylua: ignore start
-- color conversion
local color_table = {
-- lookup table for cterm colors
@ -272,7 +272,7 @@ local color_table = {
{'254', { 228, 228, 228 }},
{'255', { 238, 238, 238 }},
}
-- LuaFormatter on
-- stylua: ignore end
function M.rgb2cterm(hex_color)
local function get_color_distance(color1, color2)

View File

@ -1,7 +1,7 @@
-- Copyright (c) 2020-2021 hoob3rt
-- MIT license, see LICENSE for more details.
local Mode = {}
-- LuaFormatter off
-- stylua: ignore
Mode.map = {
['n'] = 'NORMAL',
['no'] = 'O-PENDING',
@ -33,7 +33,7 @@ Mode.map = {
['!'] = 'SHELL',
['t'] = 'TERMINAL',
}
-- LuaFormatter on
function Mode.get_mode()
local mode_code = vim.api.nvim_get_mode().mode
if Mode.map[mode_code] == nil then return mode_code end