Skip to content

Instantly share code, notes, and snippets.

@delphinus
Last active July 28, 2023 09:22
Show Gist options
  • Save delphinus/b39f92b97025a49830f1e8dcbf4e96e5 to your computer and use it in GitHub Desktop.
Save delphinus/b39f92b97025a49830f1e8dcbf4e96e5 to your computer and use it in GitHub Desktop.
Dump diagnostics from lua-language-server with errorformat
#!/bin/bash
DIR=${1:-lua}
TMP=$(mktemp -d)
lua-language-server --check "$DIR" --configpath "$PWD/.luarc.json" --logpath "$TMP"
RESULT="$TMP/check.json"
if [[ -r $RESULT ]]; then
jq --arg pwd "$PWD" -r '
to_entries[] |
(.key | gsub("^file://\($pwd)/"; "")) as $filename |
.value[] |
[
$filename,
.range.start.line + 1,
.range.start.character + 1,
"\(.message) [\(.code)]"
] | join(":")
' "$RESULT"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment