-
-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add lua-language-server to CI (#2611)
- Implement lua-language-server linter in pre-commit - Install via Nix due to lack of Ubuntu package - Apply patch for --check CLI bug using Nix overlay - Centralize linting config for VSCode, pre-commit, and CI Fixes #2576 ## Checklist - [ ] I have added [tests](https://www.cursorless.org/docs/contributing/test-case-recorder/) - [ ] I have updated the [docs](https://github.com/cursorless-dev/cursorless/tree/main/docs) and [cheatsheet](https://github.com/cursorless-dev/cursorless/tree/main/cursorless-talon/src/cheatsheet) - [ ] I have not broken the cheatsheet --------- Co-authored-by: Pokey Rule <[email protected]>
- Loading branch information
1 parent
94e9fd0
commit 6d6addc
Showing
7 changed files
with
91 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
name: "Lua Language Server Lint" | ||
description: "Lints all lua files with lua-language-server" | ||
runs: | ||
using: "composite" | ||
steps: | ||
- uses: cachix/install-nix-action@v27 | ||
with: | ||
nix_path: nixpkgs=channel:nixos-unstable | ||
- uses: DeterminateSystems/magic-nix-cache-action@v2 | ||
- run: nix profile install --accept-flake-config .#lua-language-server | ||
shell: bash | ||
- run: scripts/lint-lua-ls.sh | ||
shell: bash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"runtime.version": "Lua 5.1", | ||
"diagnostics.ignoredFiles": "Disable", | ||
"diagnostics.globals": ["vim", "talon", "it", "describe"], | ||
"workspace.ignoreDir": ["data/playground/lua/", ".luarocks", ".lua"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
|
||
# lua-language-server should be installed automatically by the flake.nix dev shell | ||
# or .github/workflows/pre-commit.yml | ||
if ! type lua-language-server &>/dev/null; then | ||
echo "ERROR: lua-language-server is not installed. Please run 'nix develop' or install it manually." | ||
exit 1 | ||
fi | ||
|
||
if [ ! -e "${CURSORLESS_REPO_ROOT-nonexistent}" ]; then | ||
CURSORLESS_REPO_ROOT=$(git rev-parse --show-toplevel) | ||
fi | ||
|
||
function check_file() { | ||
local file="$1" | ||
logpath="$(mktemp -d)" | ||
rm -rf "$logpath/check.json" | ||
result=$(lua-language-server --check "$file" \ | ||
--checklevel="Warning" \ | ||
--configpath="${CURSORLESS_REPO_ROOT}/.luarc.json" \ | ||
--logpath="$logpath") | ||
if [[ ! "$result" == *"no problems found"* ]]; then | ||
if [ -e "$logpath/check.json" ]; then | ||
cat "$logpath/check.json" | ||
else | ||
echo "ERROR: lua-language-server failed to run." | ||
echo "$result" | ||
fi | ||
return 1 | ||
|
||
fi | ||
return 0 | ||
} | ||
|
||
# lua-language-server doesn't support single file parsing, so check entire folder | ||
exit_code=0 | ||
if ! check_file "${CURSORLESS_REPO_ROOT}"; then | ||
exit_code=1 | ||
fi | ||
|
||
exit $exit_code |