diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml new file mode 100644 index 0000000..f44b6ed --- /dev/null +++ b/.github/workflows/format.yml @@ -0,0 +1,41 @@ +name: Format +on: + push: + paths: + - 'lua/**.lua' + branches: [main] + +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: 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 diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..9a839ca --- /dev/null +++ b/.prettierrc @@ -0,0 +1,14 @@ +{ + "singleQuote": true, + "tabWidth": 4, + "semi": false, + "proseWrap": "always", + "overrides": [ + { + "files": ["*.yml"], + "options": { + "tabWidth": 2 + } + } + ] +} 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