diff options
-rw-r--r-- | .github/workflows/lint.yaml | 22 | ||||
-rw-r--r-- | .pre-commit-config.yaml | 30 | ||||
-rw-r--r-- | CONTRIBUTING.md | 14 | ||||
-rwxr-xr-x | utils/bin/jdtls | 10 |
4 files changed, 57 insertions, 19 deletions
diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 87f93a00..f5aab0eb 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -22,17 +22,13 @@ jobs: - name: Run luacheck run: luacheck *.lua lua/ - - shell-linter: - name: "Linting with shellcheck" - runs-on: ubuntu-20.04 + + shellcheck: + name: Shellcheck + runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - - name: Use shellcheck - run: sudo apt-get install shellcheck - - - name: Run shellcheck - run: | - pwd - shellcheck $(find . -name "*.sh") + - uses: actions/checkout@v2 + - name: Run ShellCheck + uses: ludeeus/action-shellcheck@master + with: + scandir: './utils' diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..3e3e7d34 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,30 @@ +repos: + - repo: local + hooks: + - id: shfmt + name: shfmt + minimum_pre_commit_version: 2.4.0 + language: golang + additional_dependencies: [mvdan.cc/sh/v3/cmd/[email protected]] + entry: shfmt + args: [-i=2, -ci, -w] + types: [shell] + - id: shellcheck + name: shellcheck + language: system + types: [shell] + entry: bash + args: + [-c, "shfmt -f $(git rev-parse --show-toplevel) | xargs shellcheck"] + - id: stylua + name: StyLua + language: rust + entry: stylua + types: [lua] + args: [.] + - id: luacheck + name: luacheck + language: system + entry: luacheck + types: [lua] + args: [.] diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 7606fe46..45edf8c1 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -17,9 +17,19 @@ One of the best ways to begin contributing in a meaningful way is by helping fin ## Setting up development tools -1. Install [stylua](https://github.com/johnnymorganz/stylua#installation) +### For editing Lua files -2. Install [shfmt](https://github.com/mvdan/sh#shfmt) +1. Formatter: [stylua](https://github.com/johnnymorganz/stylua#installation). +2. Linter: [luacheck](https://github.com/luarocks/luacheck). + +### For editing shell scripts + +1. Formatter: [shfmt](https://github.com/mvdan/sh#shfmt). +2. Linter: [shellcheck](https://github.com/koalaman/shellcheck). + +### (Optional) + +Install [pre-commit](https://github.com/pre-commit/pre-commit) which will run all linters and formatters for you as a pre-commit-hook. ## Some Guidelines diff --git a/utils/bin/jdtls b/utils/bin/jdtls index 2b0f226a..961d2df5 100755 --- a/utils/bin/jdtls +++ b/utils/bin/jdtls @@ -1,4 +1,5 @@ #!/usr/bin/env bash +# shellcheck disable=SC2116 # NOTE: # This doesn't work as is on Windows. You'll need to create an equivalent `.bat` file instead @@ -7,7 +8,8 @@ # If you're not using Linux you'll need to adjust the `-configuration` option # to point to the `config_mac' or `config_win` folders depending on your system. -case Darwin in +OS="$(uname -s)" +case "$OS" in Linux) CONFIG="$HOME/.local/share/nvim/lspinstall/java/config_linux" ;; @@ -32,7 +34,7 @@ location of your Java installation." fi else JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + command -v java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." @@ -46,10 +48,10 @@ GRADLE_HOME=$HOME/gradle "$JAVACMD" \ -Declipse.product=org.eclipse.jdt.ls.core.product \ -Dlog.protocol=true \ -Dlog.level=ALL \ - -javaagent:$HOME/.local/share/nvim/lspinstall/java/lombok.jar \ + -javaagent:"$HOME/.local/share/nvim/lspinstall/java/lombok.jar" \ -Xms1g \ -Xmx2G \ - -jar $(echo "$JAR") \ + -jar "$(echo "$JAR")" \ -configuration "$CONFIG" \ -data "${1:-$HOME/workspace}" \ --add-modules=ALL-SYSTEM \ |