-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
143 lines (123 loc) · 4.68 KB
/
Copy pathMakefile
File metadata and controls
143 lines (123 loc) · 4.68 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
cwd := $(shell pwd)
## help: Print this help message
.PHONY: help
help:
@echo 'Usage:'
@sed -n 's/^##//p' ${MAKEFILE_LIST} | column -t -s ':' | sed -e 's/^/ /'
## all: Generate docs, lint, and run tests
.PHONY: all
all: doc lint test
## doc: Generate documentation. Requires pandoc and emmylua_doc_cli in PATH.
.PHONY: doc
doc: venv
@echo "• Rendering markdown docs"
@venv/bin/emmylua-render --no-expand '*InitOptsWithMeta' --format md --out README.md templates/finni.md.jinja
@echo "• Rendering vim docs"
@venv/bin/emmylua-render --no-expand '*InitOptsWithMeta' --format vim --out doc/finni.txt templates/finni.txt.jinja
## test: Run tests. If `FILE` env var is specified, searches for a matching file in `tests`. Substrings are allowed (e.g. `FILE=layout` finds tests/core/test_layout.lua).
.PHONY: test
test: deps _cleantest
@if [ -n "$(FILE)" ]; then \
FILE_NO_EXT="$$(echo "$(FILE)" | sed 's/\.lua$$//')"; \
if [ -f "tests/$$FILE_NO_EXT.lua" ]; then \
FOUND_FILE="tests/$$FILE_NO_EXT.lua"; \
elif [ -f "$$FILE_NO_EXT.lua" ]; then \
FOUND_FILE="$$FILE_NO_EXT.lua"; \
else \
FOUND_FILE="$$(find tests -path "*$$FILE_NO_EXT*.lua" -type f | head -1)"; \
fi; \
if [ -z "$$FOUND_FILE" ]; then \
echo "Error: No test file matching '$(FILE)' found in tests/"; \
exit 1; \
fi; \
echo "Running tests in: $$FOUND_FILE"; \
XDG_CONFIG_HOME="${cwd}/.test/env/config" \
XDG_DATA_HOME="${cwd}/.test/env/data" \
XDG_STATE_HOME="${cwd}/.test/env/state" \
XDG_RUNTIME_DIR="${cwd}/.test/env/run" \
XDG_CACHE_HOME="${cwd}/.test/env/cache" \
nvim --headless --noplugin -u ./scripts/minimal_init.lua -c "lua MiniTest.run_file('$$FOUND_FILE')"; \
else \
XDG_CONFIG_HOME="${cwd}/.test/env/config" \
XDG_DATA_HOME="${cwd}/.test/env/data" \
XDG_STATE_HOME="${cwd}/.test/env/state" \
XDG_RUNTIME_DIR="${cwd}/.test/env/run" \
XDG_CACHE_HOME="${cwd}/.test/env/cache" \
nvim --headless --noplugin -u ./scripts/minimal_init.lua -c "lua MiniTest.run()"; \
fi;
.PHONY: _cleantest
_cleantest: .test
@rm -rf ".test/env/cache/nvim"; \
rm -rf ".test/env/config/nvim"; \
rm -rf ".test/env/data/nvim"; \
rm -rf ".test/env/state/nvim"; \
rm -rf ".test/env/run/nvim"; \
rm -f ".test/nvim_init.lua"; \
rm -f ".test/verbose_log"
.test: .test/env
.test/env: .test/env/cache .test/env/config .test/env/data .test/env/state .test/env/run
.test/env/cache:
@mkdir -p ".test/env/cache"
.test/env/config:
@mkdir -p ".test/env/config"
.test/env/data:
@mkdir -p ".test/env/data"
.test/env/state:
@mkdir -p ".test/env/state"
.test/env/run:
@mkdir -p ".test/env/run"
## deps: Install all library dependencies
deps: deps/nvim-dap deps/fzf-lua deps/gitsigns.nvim deps/mini.nvim deps/neogit deps/oil.nvim deps/plenary.nvim deps/snacks.nvim deps/telescope.nvim
deps/nvim-dap:
@mkdir -p deps
git clone --filter=blob:none https://github.com/mfussenegger/nvim-dap $@
deps/fzf-lua:
@mkdir -p deps
git clone --filter=blob:none https://github.com/ibhagwan/fzf-lua $@
deps/gitsigns.nvim:
@mkdir -p deps
git clone --filter=blob:none https://github.com/lewis6991/gitsigns.nvim $@
deps/mini.nvim:
@mkdir -p deps
git clone --filter=blob:none https://github.com/nvim-mini/mini.nvim $@
deps/neogit:
@mkdir -p deps
git clone --filter=blob:none https://github.com/NeogitOrg/neogit $@
deps/oil.nvim:
@mkdir -p deps
git clone --filter=blob:none https://github.com/stevearc/oil.nvim $@
deps/plenary.nvim:
@mkdir -p deps
git clone --filter=blob:none https://github.com/nvim-lua/plenary.nvim $@
deps/snacks.nvim:
@mkdir -p deps
git clone --filter=blob:none https://github.com/folke/snacks.nvim $@
deps/telescope.nvim:
@mkdir -p deps
git clone --filter=blob:none https://github.com/nvim-telescope/telescope.nvim $@
## lint: Run linters, test-render md/vim docs and EmmyLuaLS typechecking
.PHONY: lint
lint: fastlint
@echo "• Static analysis with emmylua_check"
@VIMRUNTIME=$$(nvim -es '+put=$$VIMRUNTIME|print|quit!') \
emmylua_check --warnings-as-errors -c .emmyrc.json lua tests
@echo "• Checking vim doc template"
@venv/bin/emmylua-render --format vim templates/finni.txt.jinja >/dev/null
## fastlint: Run only fast linters test-render md docs
.PHONY: fastlint
fastlint: deps venv
@echo "• Checking markdown doc template"
@venv/bin/emmylua-render --format md templates/finni.md.jinja > /dev/null # todo: markdownlint?
@echo "• Basic static analysis with luacheck"
@luacheck lua tests --formatter plain
@echo "• Checking formatting"
@stylua --check lua tests
venv:
@echo "• Creating venv"
python3 -m venv venv
@echo "• Installing emmylua-render into venv"
venv/bin/pip install git+https://github.com/lkubb/emmylua-render
## clean: Reset the repository to a clean state
.PHONY: clean
clean:
rm -rf .test deps venv