Skip to content

Commit bbe47ca

Browse files
committed
ci: add luals workflow
Optional for now; can be run locally with `make luacheck`.
1 parent 0294ae3 commit bbe47ca

File tree

4 files changed

+138
-5
lines changed

4 files changed

+138
-5
lines changed

.emmyrc.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"$schema": "https://raw.githubusercontent.com/EmmyLuaLs/emmylua-analyzer-rust/refs/heads/main/crates/emmylua_code_analysis/resources/schema.json",
3+
"format": {
4+
"externalTool": {
5+
"program": "stylua",
6+
"args": [
7+
"-",
8+
"--stdin-filepath",
9+
"${file}"
10+
]
11+
}
12+
},
13+
"diagnostics": {
14+
"disable": [
15+
"unnecessary-if"
16+
]
17+
},
18+
"codeAction": {
19+
"insertSpace": true
20+
},
21+
"strict": {
22+
"typeCall": true,
23+
"arrayIndex": true
24+
}
25+
}

.github/workflows/lint.yml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ jobs:
2323
sudo luarocks install luacheck
2424
2525
- name: Lint
26-
run: sudo make lint
26+
run: make lint
2727

2828
stylua:
29-
name: stylua
29+
name: Stylua
3030
runs-on: ubuntu-latest
3131
steps:
3232
- uses: actions/checkout@v5
@@ -35,4 +35,12 @@ jobs:
3535
token: ${{ secrets.GITHUB_TOKEN }}
3636
version: latest
3737
# CLI arguments
38-
args: --color always --check lua/
38+
args: --color always --check .
39+
40+
luals:
41+
name: Luals
42+
runs-on: ubuntu-latest
43+
steps:
44+
- uses: actions/checkout@v5
45+
- run: make checklua
46+

.luarc.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"$schema": "https://raw.githubusercontent.com/LuaLS/vscode-lua/master/setting/schema.json",
3+
"runtime": {
4+
"version": "LuaJIT"
5+
},
6+
"workspace": {
7+
"library": [
8+
"$VIMRUNTIME"
9+
],
10+
"ignoreDir": [
11+
".test-deps",
12+
"lua/tests"
13+
],
14+
"checkThirdParty": "Disable"
15+
},
16+
"diagnostics": {
17+
"groupFileStatus": {
18+
"strict": "Opened",
19+
"strong": "Opened"
20+
},
21+
"groupSeverity": {
22+
"strong": "Warning",
23+
"strict": "Warning"
24+
},
25+
"unusedLocalExclude": [ "_*" ]
26+
}
27+
}

Makefile

Lines changed: 75 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,83 @@
1-
.PHONY: test lint docgen
1+
NVIM_VERSION ?= nightly
2+
LUALS_VERSION := 3.15.0
23

4+
DEPDIR ?= .test-deps
5+
CURL ?= curl -sL --create-dirs
6+
7+
ifeq ($(shell uname -s),Darwin)
8+
NVIM_ARCH ?= macos-arm64
9+
LUALS_ARCH ?= darwin-arm64
10+
STYLUA_ARCH ?= macos-aarch64
11+
else
12+
NVIM_ARCH ?= linux-x86_64
13+
LUALS_ARCH ?= linux-x64
14+
STYLUA_ARCH ?= linux-x86_64
15+
endif
16+
17+
# download test dependencies
18+
19+
NVIM := $(DEPDIR)/nvim-$(NVIM_ARCH)
20+
NVIM_TARBALL := $(NVIM).tar.gz
21+
NVIM_URL := https://github.com/neovim/neovim/releases/download/$(NVIM_VERSION)/$(notdir $(NVIM_TARBALL))
22+
NVIM_BIN := $(NVIM)/nvim-$(NVIM_ARCH)/bin/nvim
23+
NVIM_RUNTIME=$(NVIM)/nvim-$(NVIM_ARCH)/share/nvim/runtime
24+
25+
.PHONY: nvim
26+
nvim: $(NVIM)
27+
28+
$(NVIM):
29+
$(CURL) $(NVIM_URL) -o $(NVIM_TARBALL)
30+
mkdir $@
31+
tar -xf $(NVIM_TARBALL) -C $@
32+
rm -rf $(NVIM_TARBALL)
33+
34+
LUALS := $(DEPDIR)/lua-language-server-$(LUALS_VERSION)-$(LUALS_ARCH)
35+
LUALS_TARBALL := $(LUALS).tar.gz
36+
LUALS_URL := https://github.com/LuaLS/lua-language-server/releases/download/$(LUALS_VERSION)/$(notdir $(LUALS_TARBALL))
37+
38+
.PHONY: luals
39+
luals: $(LUALS)
40+
41+
$(LUALS):
42+
$(CURL) $(LUALS_URL) -o $(LUALS_TARBALL)
43+
mkdir $@
44+
tar -xf $(LUALS_TARBALL) -C $@
45+
rm -rf $(LUALS_TARBALL)
46+
47+
STYLUA := $(DEPDIR)/stylua-$(STYLUA_ARCH)
48+
STYLUA_TARBALL := $(STYLUA).zip
49+
STYLUA_URL := https://github.com/JohnnyMorganz/StyLua/releases/latest/download/$(notdir $(STYLUA_TARBALL))
50+
51+
.PHONY: stylua
52+
stylua: $(STYLUA)
53+
54+
$(STYLUA):
55+
$(CURL) $(STYLUA_URL) -o $(STYLUA_TARBALL)
56+
unzip $(STYLUA_TARBALL) -d $(STYLUA)
57+
rm -rf $(STYLUA_TARBALL)
58+
59+
.PHONY: formatlua
60+
formatlua: $(STYLUA)
61+
$(STYLUA)/stylua .
62+
63+
.PHONY: checklua
64+
checklua: $(LUALS) $(NVIM)
65+
VIMRUNTIME=$(NVIM_RUNTIME) $(LUALS)/bin/lua-language-server \
66+
--configpath=../.luarc.json \
67+
--check=./
68+
69+
.PHONY: test
370
test:
471
nvim --headless --noplugin -u scripts/minimal_init.vim -c "PlenaryBustedDirectory lua/tests/automated/ { minimal_init = './scripts/minimal_init.vim' }"
572

6-
lint:
73+
.PHONY: lint
74+
luacheck:
775
luacheck lua/telescope
876

77+
.PHONY: docgen
978
docgen:
1079
nvim --headless --noplugin -u scripts/minimal_init.vim -c "luafile ./scripts/gendocs.lua" -c 'qa'
80+
81+
.PHONY: clean
82+
clean:
83+
rm -rf $(DEPDIR)

0 commit comments

Comments
 (0)