From 9751d7206aa12b13fd8cebbbb7aab1c01e6a6b47 Mon Sep 17 00:00:00 2001 From: aarondill Date: Sun, 5 Nov 2023 15:12:12 -0600 Subject: [PATCH] chore: add formatting workflow and stylua.toml These should ensure consitent formatting in the future. Feel free to modify the stylua.toml to your liking. I tried to keep it consistent with our current style (especially the tab-based indention) --- .github/workflows/lua-format-check-pr.yml | 16 ++++++++++++++++ .github/workflows/lua-format-push.yml | 21 +++++++++++++++++++++ .luarc.json | 9 ++++----- stylua.toml | 9 +++++++++ 4 files changed, 50 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/lua-format-check-pr.yml create mode 100644 .github/workflows/lua-format-push.yml create mode 100644 stylua.toml diff --git a/.github/workflows/lua-format-check-pr.yml b/.github/workflows/lua-format-check-pr.yml new file mode 100644 index 0000000..3d438ec --- /dev/null +++ b/.github/workflows/lua-format-check-pr.yml @@ -0,0 +1,16 @@ +name: Check Lint With Stylua +on: + pull_request: + paths: + - "**.lua" +jobs: + format_code: + if: github.repository != github.event.pull_request.base.repo.full_name # if not a local branch + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: JohnnyMorganz/stylua-action@v3 + with: + token: ${{ secrets.GITHUB_TOKEN }} + version: latest + args: --check . diff --git a/.github/workflows/lua-format-push.yml b/.github/workflows/lua-format-push.yml new file mode 100644 index 0000000..0cc6da5 --- /dev/null +++ b/.github/workflows/lua-format-push.yml @@ -0,0 +1,21 @@ +name: Lint With Stylua +on: + push: + paths: + - "**.lua" + workflow_dispatch: +jobs: + format_code: + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - uses: actions/checkout@v3 + - uses: JohnnyMorganz/stylua-action@v3 + with: + token: ${{ secrets.GITHUB_TOKEN }} + version: latest + args: . + - uses: stefanzweifel/git-auto-commit-action@v4 + with: + commit_message: "chore: linting with Stylua" diff --git a/.luarc.json b/.luarc.json index c11a453..fd86372 100644 --- a/.luarc.json +++ b/.luarc.json @@ -1,6 +1,5 @@ { - "$schema": "https://raw.githubusercontent.com/sumneko/vscode-lua/master/setting/schema.json", - "Lua.diagnostics.globals": [ - "autocomplete" - ] -} \ No newline at end of file + "$schema": "https://raw.githubusercontent.com/sumneko/vscode-lua/master/setting/schema.json", + "Lua.diagnostics.globals": ["autocomplete"], + "unusedLocalExclude": ["_*"] +} diff --git a/stylua.toml b/stylua.toml new file mode 100644 index 0000000..e1d5d47 --- /dev/null +++ b/stylua.toml @@ -0,0 +1,9 @@ +column_width = 120 +line_endings = "Unix" +indent_type = "Tabs" +quote_style = "AutoPreferDouble" +call_parentheses = "Always" +collapse_simple_statement = "ConditionalOnly" + +[sort_requires] +enabled = true