-
-
Notifications
You must be signed in to change notification settings - Fork 224
Expand file tree
/
Copy pathMakefile
More file actions
165 lines (129 loc) · 4.52 KB
/
Makefile
File metadata and controls
165 lines (129 loc) · 4.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
.DEFAULT_GOAL := test
export XDG_DATA_HOME ?= $(HOME)/.data
# ------------------------------------------------------------------------------
# nvim-treesitter
# ------------------------------------------------------------------------------
NVIM_TS_SHA ?= d72fa25
NVIM_TS := deps/nvim-treesitter
.PHONY: nvim-treesitter
nvim-treesitter: $(NVIM_TS)
$(NVIM_TS):
git clone \
--filter=blob:none \
https://github.com/nvim-treesitter/nvim-treesitter $@
cd $@ && git checkout $(NVIM_TS_SHA)
# ------------------------------------------------------------------------------
# Nvim-test
# ------------------------------------------------------------------------------
FILTER=.*
export NVIM_TEST_VERSION ?= v0.11.5
export NVIM_RUNNER_VERSION ?= v0.11.5
NVIM_TEST := deps/nvim-test
NVIM_TEST_REV = v1.1.0
.PHONY: nvim-test
nvim-test: $(NVIM_TEST)
$(NVIM_TEST):
git clone \
--filter=blob:none \
--branch $(NVIM_TEST_REV) \
https://github.com/lewis6991/nvim-test $@
$(NVIM_TEST)/bin/nvim-test --init
.PHONY: test
test: $(NVIM_TEST) $(NVIM_TS)
$(NVIM_TEST)/bin/nvim-test test \
--runner_version $(NVIM_RUNNER_VERSION) \
--target_version $(NVIM_TEST_VERSION) \
--lpath=$(PWD)/lua/?.lua \
--filter="$(FILTER)" \
--verbose
.PHONY: parsers
parsers: $(NVIM_TEST) $(NVIM_TS)
$(XDG_DATA_HOME)/nvim-test/nvim-runner-$(NVIM_RUNNER_VERSION)/bin/nvim \
-l test/helpers.lua install
# ------------------------------------------------------------------------------
# LuaLS
# ------------------------------------------------------------------------------
ifeq ($(shell uname -m),arm64)
LUALS_ARCH ?= arm64
else
LUALS_ARCH ?= x64
endif
LUALS_VERSION := 3.13.6
LUALS := deps/lua-language-server-$(LUALS_VERSION)-$(shell uname -s)-$(LUALS_ARCH)
LUALS_TARBALL := $(LUALS).tar.gz
LUALS_URL := https://github.com/LuaLS/lua-language-server/releases/download/$(LUALS_VERSION)/$(notdir $(LUALS_TARBALL))
.PHONY: luals
luals: $(LUALS)
$(LUALS):
wget --directory-prefix=$(dir $@) $(LUALS_URL)
mkdir -p $@
tar -xf $(LUALS_TARBALL) -C $@
rm -rf $(LUALS_TARBALL)
.PHONY: luals-check
luals-check: $(LUALS) $(NVIM_TEST)
VIMRUNTIME=$(XDG_DATA_HOME)/nvim-test/nvim-test-$(NVIM_TEST_VERSION)/share/nvim/runtime \
$(LUALS)/bin/lua-language-server \
--configpath=../.luarc.json \
--check=lua
# ------------------------------------------------------------------------------
# Stylua
# ------------------------------------------------------------------------------
ifeq ($(shell uname -s),Darwin)
STYLUA_PLATFORM := macos-aarch64
else
STYLUA_PLATFORM := linux-x86_64
endif
# ------------------------------------------------------------------------------
# Stylua
# ------------------------------------------------------------------------------
STYLUA_VERSION := v2.1.0
STYLUA_ZIP := stylua-$(STYLUA_PLATFORM).zip
STYLUA_URL := https://github.com/JohnnyMorganz/StyLua/releases/download/$(STYLUA_VERSION)/$(STYLUA_ZIP)
STYLUA := deps/stylua
.INTERMEDIATE: $(STYLUA_ZIP)
$(STYLUA_ZIP):
wget $(STYLUA_URL)
.PHONY: stylua
stylua: $(STYLUA)
$(STYLUA): $(STYLUA_ZIP)
unzip $< -d $(dir $@)
LUA_FILES := $(shell git ls-files 'lua/*.lua' 'test/*_spec.lua')
.PHONY: stylua-check
stylua-check: $(STYLUA)
$(STYLUA) --check $(LUA_FILES)
@! grep -n -- '---.*nil' $(LUA_FILES) \
|| (echo "Error: Found 'nil' in annotation, please use '?'" && exit 1)
@! grep -n -- '---@' $(LUA_FILES) \
|| (echo "Error: Found '---@' in Lua files, please use '--- @'" && exit 1)
.PHONY: stylua-run
stylua-run: $(STYLUA)
$(STYLUA) $(LUA_FILES)
perl -pi -e 's/---@/--- @/g' $(LUA_FILES)
# ------------------------------------------------------------------------------
# Tsqueryls
# ------------------------------------------------------------------------------
ifeq ($(shell uname -s),Darwin)
TSQUERYLS_PLATFORM := aarch64-apple-darwin
else
TSQUERYLS_PLATFORM := x86_64-unknown-linux-gnu
endif
TSQUERYLS := deps/ts_query_ls-$(TSQUERYLS_PLATFORM)
TSQUERYLS_TARBALL := $(TSQUERYLS).tar.gz
TSQUERYLS_URL := https://github.com/ribru17/ts_query_ls/releases/latest/download/$(notdir $(TSQUERYLS_TARBALL))
.PHONY: tsqueryls
tsqueryls: $(TSQUERYLS)
$(TSQUERYLS):
wget --directory-prefix=$(dir $@) $(TSQUERYLS_URL)
mkdir -p $@
tar -xf $(TSQUERYLS_TARBALL) -C $@
rm -rf $(TSQUERYLS_TARBALL)
QUERIES := queries/
.PHONY: tsqueryls-lint
tsqueryls-lint: $(TSQUERYLS)
$(TSQUERYLS)/ts_query_ls lint $(QUERIES)
.PHONY: tsqueryls-format
tsqueryls-format: $(TSQUERYLS)
$(TSQUERYLS)/ts_query_ls format $(QUERIES)
.PHONY: tsqueryls-check
tsqueryls-check: $(TSQUERYLS)
$(TSQUERYLS)/ts_query_ls check $(QUERIES)