From d4bbd3aaa08dd72568126578a85b7acb2de616ac Mon Sep 17 00:00:00 2001 From: Michael Chris Lopez Date: Fri, 29 Oct 2021 17:00:45 +0800 Subject: [PATCH 1/4] chore: add prettier config --- .prettierrc | 6 ++++++ README.md | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 .prettierrc diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..94d7f96 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,6 @@ +{ + "singleQuote": true, + "tabWidth": 4, + "semi": false, + "proseWrap": "always" +} diff --git a/README.md b/README.md index 41e5934..b709ba9 100644 --- a/README.md +++ b/README.md @@ -95,7 +95,7 @@ currently supported. - [WhichKey](https://github.com/folke/which-key.nvim) - [Trouble](https://github.com/folke/trouble.nvim) - [NvimTree](https://github.com/kyazdani42/nvim-tree.lua) -- [Nnn](https://github.com/mcchrish/nnn.vim) +- [n³](https://github.com/mcchrish/nnn.vim) ## Other implementations From 834189a64aeefe7e1eebfc43c2c47546f0d83f92 Mon Sep 17 00:00:00 2001 From: Michael Chris Lopez Date: Fri, 29 Oct 2021 17:09:19 +0800 Subject: [PATCH 2/4] prettier override yml --- .prettierrc | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.prettierrc b/.prettierrc index 94d7f96..9a839ca 100644 --- a/.prettierrc +++ b/.prettierrc @@ -2,5 +2,13 @@ "singleQuote": true, "tabWidth": 4, "semi": false, - "proseWrap": "always" + "proseWrap": "always", + "overrides": [ + { + "files": ["*.yml"], + "options": { + "tabWidth": 2 + } + } + ] } From f3d1c98d6d14384e91eb4d46ad9ed2ff734981d4 Mon Sep 17 00:00:00 2001 From: Michael Chris Lopez Date: Fri, 29 Oct 2021 17:11:23 +0800 Subject: [PATCH 3/4] add format workflow --- .github/workflows/format.yml | 46 ++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 .github/workflows/format.yml diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml new file mode 100644 index 0000000..e2d0f41 --- /dev/null +++ b/.github/workflows/format.yml @@ -0,0 +1,46 @@ +name: Format +on: + push: + paths: + - 'lua/**.lua' + - '**.md' + - '.github/**.yml' + branches: [main, dev] + +jobs: + format: + runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + STYLUA_VERSION: 0.11.0 + 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/ + + - name: Apply prettier + uses: creyD/prettier_action@v4.0 + + - name: Create PR + run: | + if ! [[ -z $(git status -s) ]]; then + git add -u + git commit -m "chore: format" + 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 From df6f9dea59c02f5c9c938d23f67fcc12e28292ee Mon Sep 17 00:00:00 2001 From: Michael Chris Lopez Date: Fri, 29 Oct 2021 17:20:40 +0800 Subject: [PATCH 4/4] fix prettier options --- .github/workflows/format.yml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index e2d0f41..f44b6ed 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -3,9 +3,7 @@ on: push: paths: - 'lua/**.lua' - - '**.md' - - '.github/**.yml' - branches: [main, dev] + branches: [main] jobs: format: @@ -33,9 +31,6 @@ jobs: chmod +x /tmp/stylua /tmp/stylua --config-path=.stylua.toml lua/ - - name: Apply prettier - uses: creyD/prettier_action@v4.0 - - name: Create PR run: | if ! [[ -z $(git status -s) ]]; then