Skip to content

Commit e02ba60

Browse files
committed
chore: add codestyle-check option to luals-check.sh
1 parent bb46ca0 commit e02ba60

File tree

3 files changed

+22
-6
lines changed

3 files changed

+22
-6
lines changed

.editorconfig

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ end_of_line = lf
77
[nvim-tree-lua.txt]
88
max_line_length = 78
99

10-
# keep these in sync with .luarc.json so that lua-language-server may check/apply standalone
10+
# keep these in sync with .luarc.json
11+
# .editorconfig is used within nvim, overriding .luarc.json
12+
# .luarc.json is used by style check
1113
[*.lua]
1214
indent_style = space
1315
max_line_length = 140

.luarc.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
22
"$schema": "https://raw.githubusercontent.com/sumneko/vscode-lua/master/setting/schema.json",
3-
"runtime.version.luals-check-only": "Lua 5.1",
43
"workspace": {
54
"library": [
65
"$VIMRUNTIME/lua/vim",

scripts/luals-check.sh

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
# luals-out/check.json will be produced on any issues, returning 1.
55
# Outputs only check.json to stdout, all other messages to stderr, to allow jq etc.
66
# $VIMRUNTIME specifies neovim runtime path, defaults to "/usr/share/nvim/runtime" if unset.
7+
#
8+
# Call with codestyle-check param to enable only codestyle-check
79

810
if [ -z "${VIMRUNTIME}" ]; then
911
export VIMRUNTIME="/usr/share/nvim/runtime"
@@ -17,11 +19,24 @@ FILE_LUARC="${DIR_OUT}/luarc.json"
1719
rm -rf "${DIR_OUT}"
1820
mkdir "${DIR_OUT}"
1921

20-
# Uncomment runtime.version for strict neovim baseline 5.1
21-
# It is not set normally, to prevent luals loading 5.1 and 5.x, resulting in both versions being chosen on vim.lsp.buf.definition()
22-
cat "${PWD}/.luarc.json" | sed -E 's/.luals-check-only//g' > "${FILE_LUARC}"
22+
case "${1}" in
23+
"codestyle-check")
24+
jq \
25+
'.diagnostics.neededFileStatus[] = "None" | ''.diagnostics.neededFileStatus."codestyle-check" = "Any"' \
26+
"${PWD}/.luarc.json" > "${FILE_LUARC}"
2327

24-
# execute inside lua to prevent luals itself from being checked
28+
;;
29+
*)
30+
# Add runtime.version for strict neovim baseline 5.1
31+
# It is not set normally, to prevent luals loading 5.1 and 5.x, resulting in both versions being chosen on vim.lsp.buf.definition
32+
jq \
33+
'."runtime.version" = "Lua 5.1"' \
34+
"${PWD}/.luarc.json" > "${FILE_LUARC}"
35+
36+
;;
37+
esac
38+
39+
# execute inside lua directory to prevent luals itself from being checked
2540
OUT=$(lua-language-server --check="${DIR_SRC}" --configpath="${FILE_LUARC}" --checklevel=Information --logpath="${DIR_OUT}" --loglevel=error)
2641
RC=$?
2742

0 commit comments

Comments
 (0)