-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
executable file
·401 lines (349 loc) · 14.7 KB
/
Makefile
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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
OS := $(shell hostnamectl status | grep -i 'Operating System' | cut -d: -f2 | tr -d '[0-9. ]' | tr '[:upper:]' '[:lower:]')
.PHONY: all tools check nvim linter lang/go lang/php lang/lua lang/rust
# https://github.com/neovim/nvim-lspconfig
all:
tools
tools/zsh
linter
lang/go
lang/rust
lang/php
lang/lua
tools/cloud
-@make $(OS)
archlinux: prepare/$(OS)
ubuntu: prepare/$(OS) tools/$(OS) tools/rust tools/go lua/$(OS) yarn/$(OS) vala/$(OS) luarocks symlink/ubuntu
prepare/archlinux:
sudo pacman -S npm python-pip tree-sitter clang
sudo pacman -S lua51 lua51-lpeg-patterns luajit
sudo ln -sf /usr/bin/lua5.1 /usr/local/bin/lua
export LUAROCKS_CONFIG=~/.luarocks/config-5.1.lua
prepare/ubuntu: ts-cli
command -v ninja || sudo apt-get install -y ninja-build
tools:
npm config set prefix ~/.local && npm config set registry=http://registry.npm.taobao.org
npm i -g npm
npm install -g fixjson
npm install -g jsonlint
npm i -g bash-language-server
# General purpose Language Server that integrate with linter to support diagnostic features
# https://github.com/iamcco/diagnostic-languageserver
npm i -g diagnostic-languageserver
npm install -g dockerfile-language-server-nodejs
# get vscode-html-language-server, vscode-css-language-server and vscode-json-language-server
# https://github.com/hrsh7th/vscode-langservers-extracted
npm i -g vscode-langservers-extracted
# https://www.npmjs.com/package/@tailwindcss/language-server
npm i -g @tailwindcss/language-server
# python https://github.com/microsoft/pyright
npm install -g pyright
npm install -g typescript-language-server
npm install -g vim-language-server
# markdown linter https://github.com/igorshubovych/markdownlint-cli
# npm install -g markdownlint-cli
# https://vale.sh/docs/vale-cli/installation/
go install github.com/errata-ai/vale/v2/cmd/vale@latest
# fedora
test -L /etc/fedora-release && sudo dnf copr enable -y mczernek/vale && sudo dnf install -y vale
# vue
npm install -g vls
# does not install via npm https://github.com/redhat-developer/yaml-language-server
yarn global add yaml-language-server
go install github.com/UltiRequiem/yamlfmt@latest
pip3 install --user --upgrade pynvim
# https://github.com/mhinz/neovim-remote
pip3 install --user --upgrade neovim-remote
# https://github.com/mvdan/sh
go install mvdan.cc/sh/v3/cmd/shfmt@latest
tools/archlinux:
sudo pacman -S --needed mkcert
# sudo pacman -S copyq
# https://github.com/koalaman/shellcheck#installing
paru -S --needed shellcheck-static
# markdown linter https://github.com/errata-ai/vale
#paru -S --needed vale-bin
curl -SsfL https://github.com/errata-ai/vale/releases/download/v2.23.0/vale_2.23.0_Linux_64-bit.tar.gz | bsdtar -xzf - -C$$HOME/.local/bin/
# https://github.com/hadolint/hadolint
paru -S --needed hadolint-bin
lang/go:
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(shell go env GOPATH)/bin
golangci-lint --version
go install golang.org/x/tools/gopls@latest
go install github.com/go-delve/delve/cmd/dlv@latest
go install github.com/mgechev/revive
go install golang.org/x/tools/cmd/goimports
go install mvdan.cc/gofumpt/gofumports
go install github.com/fatih/gomodifytags
go install github.com/josharian/impl
# binary optimze
go install github.com/jondot/goweight
go install github.com/bradfitz/shotizam
# go test with colors
go install github.com/rakyll/gotest
go install github.com/kyoh86/richgo
# 🦀 https://www.rust-lang.org/tools/install
lang/rust:
# curl -LZ https://github.com/rust-analyzer/rust-analyzer/releases/latest/download/rust-analyzer-x86_64-unknown-linux-gnu.gz | gunzip -c - > ~/.local/bin/rust-analyzer && chmod +x ~/.local/bin/rust-analyzer
# https://rust-analyzer.github.io/manual.html#rustup
rustup component add rust-analyzer
# However, in contrast to component add clippy or component add rustfmt, this does not actually place a rust-analyzer binary in ~/.cargo/bin, see this issue.
# https://github.com/rust-lang/rustup/issues/2411
ln -s $(rustup which --toolchain stable rust-analyzer) ~/.cargo/bin/
# cargo add / rm / upgrade https://github.com/killercup/cargo-edit
cargo install cargo-edit
# https://github.com/kbknapp/cargo-outdated
cargo install --locked cargo-outdated
# https://github.com/svenstaro/cargo-profiler
cargo install cargo-profiler
# cargo-machete is a Cargo tool that detects unused dependencies in Rust projects
# https://github.com/bnjbvr/cargo-machete
cargo install cargo-machete
# https://github.com/RazrFalcon/cargo-bloat
cargo install cargo-bloat --features regex-filter
# https://doc.rust-lang.org/book/appendix-07-nightly-rust.html#rustup-and-the-role-of-rust-nightly
rustup toolchain install nightly
rustup toolchain list
# cd ~/projects/needs-nightly
# rustup override set nightly
lang/php:
# php intelephense 1.7.1 https://www.npmjs.com/package/intelephense
npm install -g intelephense
lang/lua:
# https://github.com/lunarmodules/LDoc
luarocks install penlight && luarocks install ldoc
# https://github.com/jhawthorn/fzy
# apt-get install fzy
# https://github.com/swarn/fzy-lua
luarocks install --local fzy
# related works: https://github.com/romgrk/fzy-lua-native
# https://github.com/mpeterv/luacheck
luarocks install --local luacheck
# lang server https://github.com/LuaLS/lua-language-server/wiki/Build-and-Run-(Standalone)
# need `sudo dnf install -y libstdc++-static` under Fedora
test -L /etc/fedora-release && sudo dnf install -y libstdc++-static
git clone https://github.com/LuaLS/lua-language-server ~/.local/share/lua-language-server; \
cd ~/.local/share/lua-language-server; \
git submodule update --init --recursive; \
cd ~/.local/share/lua-language-server/3rd/luamake; \
./compile/install.sh;\
cd ~/.local/share/lua-language-server; \
./3rd/luamake/luamake rebuild
linter:
# https://yamllint.readthedocs.io/en/stable/quickstart.html#installing-yamllint
pip3 install --user --upgrade yamllint
# https://github.com/Vimjas/vint
pip3 install --user --upgrade vim-vint
# toml lint
go install -u github.com/pelletier/go-toml/cmd/tomll
# https://github.com/vmchale/tomlcheck
# curl -o~/.local/bin/tomlcheck -LZ \
# https://github.com/vmchale/tomlcheck/releases/download/0.1.0.38/tomlcheck-x86_64-unkown-linux-gnu
# dockerfile lint
curl -LZ -o ~/.local/bin/hadolint https://github.com/hadolint/hadolint/releases/download/v2.6.0/hadolint-Linux-x86_64 && chmod a+rx ~/.local/bin/hadolint
check:
nvim -i NONE -c "checkhealth"
ts:
nvim -i NONE -c "TSUninstall all" -c "qa"
nvim -i NONE -c "TSInstallFromGrammar query c go rust php python lua json toml vue css html bash"
ts-cli:
git clone https://github.com/tree-sitter/tree-sitter.git
cd tree-sitter && cargo install .
pack/p:
nvim -i NONE -c "PackerCompile profile=true" -c "PackerProfile"
pack/s:
nvim -i NONE -c "PackerSync" -c "PackerCompile"
pack/i:
nvim -i NONE -c "PackerInstall" -c "PackerCompile"
pack/c:
nvim -i NONE -c "PackerCompile" -c "qa"
pack/u:
nvim -i NONE -c "PackerUpdate"
pack/q:
nvim -i NONE -c "PackerUpdate" -c "qa"
lua/ubuntu:
sudo apt-get install -y libluajit-5.1-dev liblua5.1-0-dev
yarn/ubuntu:
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt update && sudo apt install yarn
#export PATH="$PATH:`yarn global bin`"
vala/ubuntu:
# https://github.com/benwaffle/vala-language-server
sudo apt-add-repository ppa:vala-team/next
sudo apt-get install valac valac-bin libvala-0.52-dev
# ls
sudo add-apt-repository ppa:prince781/vala-language-server
sudo apt-get update
sudo apt-get install vala-language-server
sudo apt install -y meson
# for vala ls
sudo apt install -y libgee-0.8-dev libjsonrpc-glib-1.0-dev scdoc
# for peek
sudo apt install -y libkeybinder-3.0-dev appstream-util txt2man
tools/ubuntu:
# https://clangd.llvm.org/installation.html
# clangd for c lang server, clang for build LuaLS/lua-language-server
sudo apt install -y clangd clang
# Ubuntu 20.10 and newer
sudo apt-get -y update
sudo apt-get -y install podman
sudo apt install -y universal-ctags
# https://github.com/hluk/CopyQ
sudo add-apt-repository ppa:hluk/copyq
sudo apt update
sudo apt install copyq
# https://github.com/FiloSottile/mkcert
go install filippo.io/mkcert
tools/fedora:
sudo install -y copyq
devel/fedora:
# or sudo dnf builddep neovim
# compat-lua is lua5.1
sudo dnf groupinstall -y "Development Tools" "Development Libraries"
sudo dnf install -y cmake ninja-build gcc-c++ libtool
luarocks:
# append this to .zshrc to setup correct lua env vars: eval "$(luarocks path --bin)"
curl -LZO https://luarocks.org/releases/luarocks-3.3.1.tar.gz
tar xvzpf luarocks-3.3.1.tar.gz && \
cd luarocks-3.3.1 && \
./configure --with-lua-include=/usr/include/lua-5.1/ && \
sudo make bootstrap
tools/zsh:
# rg zsh auto complete
# remember to append `fpath+=${ZDOTDIR:-~}/.zsh_functions` to ~/.zshrc
curl -fLo $${ZDOTDIR:-~}/.zsh_functions/_rg --create-dirs https://github.com/BurntSushi/ripgrep/raw/master/complete/_rg
curl -fLo $${ZDOTDIR:-~}/.zsh_functions/_fd --create-dirs https://github.com/sharkdp/fd/blob/master/contrib/completion/_fd
# bat completion is disabled due to https://github.com/sharkdp/bat/pull/482/files
tools/rust:
# https://github.com/chmln/sd
command -v sd || cargo install sd
# https://github.com/BurntSushi/ripgrep
command -v rg || cargo install ripgrep
# https://github.com/sharkdp/fd
command -v fd || cargo install fd-find
# https://github.com/sharkdp/bat
command -v bat || cargo install bat
# https://github.com/svenstaro/miniserve
command -v miniserve || cargo install miniserve
# sk fuzzy finder https://github.com/lotabout/skim
command -v sk || cargo install skim
# https://github.com/Peltoche/lsd
command -v lsd || cargo install lsd
# https://github.com/ajeetdsouza/zoxide eval "$(zoxide init zsh)"
command -v zoxide|| cargo install zoxide
# https://github.com/yaa110/nomino
cargo install nomino
# https://github.com/kl/sub-batch
cargo install sub-batch
# Yet another HTTPie clone in Rust https://github.com/ducaale/xh
cargo install xh
# source code line count https://github.com/XAMPPRocky/tokei#installation
cargo install tokei --features all
# git commit --fixup, but automatic
cargo install git-absorb
tools/go:
# https://github.com/gsamokovarov/jump
# ~/.zshrc put: eval "$(jump shell --bind=z)"
go install github.com/gsamokovarov/jump
# https://github.com/ayoisaiah/f2#installation
go install -u github.com/ayoisaiah/f2/cmd/...
# The power of curl, the ease of use of httpie. https://github.com/rs/curlie
go install -u github.com/rs/curlie
# It's like curl -v, with colours. https://github.com/davecheney/httpstat
go install github.com/davecheney/httpstat
# convert csv/tsv to markdown table https://github.com/monochromegane/mdt
go install github.com/monochromegane/mdt/...
tools/cloud:
go install github.com/juliosueiras/nomad-lsp
go github.com/juliosueiras/terraform-lsp
go install github.com/hashicorp/hcl/v2/cmd/hclfmt
push:
git push origin main --tags
pull:
git pull origin main --ff-only --tags
image:
export REGISTRY_AUTH_FILE=/etc/containers/auth.json
sudo touch /etc/containers/auth.json && \
test -s /etc/containers/auth.json || echo '{}' | sudo tee /etc/containers/auth.json && \
sudo chmod 600 /etc/containers/auth.json
sudo BUILDAH_FORMAT=docker BUILDAH_LAYERS=true podman build -t neovim .
packer:
git clone https://github.com/wbthomason/packer.nvim \
~/.local/share/nvim/site/pack/packer/opt/packer.nvim
install:
ansible-playbook -K ./nvim-fedora.yaml
# for ArchLinux you need to unset lua5.4 env vars
# because it belongs to lua 5.4 which will mess the build (make neovim link to the wrong lpeg.so)
# eval "$(luarocks --lua-version 5.1 path --bin)"
# nvim: export LUA_CPATH=/home/ttys3/.config/nvim/neovim/.deps/usr/lib/lua/5.1/?.so;/home/ttys3/.luarocks/lib64/lua/5.1/?.so
# unset LUAROCKS_CONFIG LUA_PATH LUA_CPATH
# try run `make distclean` first if link failed
unexport LUAROCKS_CONFIG
unexport LUA_PATH
unexport LUA_CPATH
nvim:
@echo "==> Checking neovim repository..."
test -d neovim || git clone https://github.com/neovim/neovim.git
@echo "==> Building neovim..."
cd neovim && \
git clean -df . && \
git checkout stable && \
git pull origin stable --tags --force && \
make distclean && \
make CMAKE_BUILD_TYPE=RelWithDebInfo || { echo "Build failed"; exit 1; }
@echo "==> Installing neovim..."
cd neovim && sudo rm -rf /usr/local/share/nvim/runtime && sudo make install
@echo "==> Testing neovim installation..."
command -v nvim >/dev/null 2>&1 || { echo "Neovim installation failed"; exit 1; }
nvim -V1 -v
@echo "==> Updating treesitter..."
# update treesitter to avoid errors like:
# Error executing lua: treesitter/query.lua:252: Query error at 5:8. Invalid node type "string_content"
nvim -i NONE -c "TSUpdateSync" -c "qa"
@echo "==> Neovim installation completed successfully"
symlink/ubuntu:
# show current alternatives
update-alternatives --list editor
update-alternatives --list vi
update-alternatives --list vim
# register nvim to alternatives
sudo update-alternatives --install /usr/bin/vi vi /usr/local/bin/nvim 60
sudo update-alternatives --install /usr/bin/vim vim /usr/local/bin/nvim 60
sudo update-alternatives --install /usr/bin/editor editor /usr/local/bin/nvim 60
# display
update-alternatives --display vi
update-alternatives --display vim
update-alternatives --display editor
# config nvim as default
sudo update-alternatives --set vi /usr/local/bin/nvim
sudo update-alternatives --set vim /usr/local/bin/nvim
sudo update-alternatives --set editor /usr/local/bin/nvim
# interactive config
# sudo update-alternatives --config editor
# sudo update-alternatives --config vi
# pure all before debug problems
purge:
rm -rf ~/.local/share/nvim && mkdir ~/.local/share/nvim && rm -rf ~/.cache/nvim && mkdir ~/.cache/nvim && rm -rf rm -rf /tmp/site
# curl -fLo $$HOME/.local/share/nvim/site/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
# https://github.com/wbthomason/packer.nvim
# git clone https://github.com/wbthomason/packer.nvim ~/.local/share/nvim/site/pack/packer/start/packer.nvim
# take screenshot of statusline
bar:
# xrandr
# xwininfo
# xwininfo -id $(xdotool getactivewindow)
rm -f {n,i,v,r,statusline}.png
scrot -o -c -d8 -a0,1938,1910,34 n.png
scrot -o -c -d8 -a0,1938,1910,34 i.png
scrot -o -c -d8 -a0,1938,1910,34 v.png
scrot -o -c -d8 -a0,1938,1910,34 r.png
ffmpeg -y -i n.png -i i.png -i v.png -i r.png -filter_complex "[0][1][2][3]vstack=inputs=4" statusline.png
xdg-open statusline.png
startuptime:
nvim --startuptime startup.log -c ":q" && cat startup.log && rm -f startup.log
plugtime:
nvim --startuptime startup.log -c ":q" && cat startup.log | sort -k2 && rm -f startup.log
debug:
- rm -f bat /tmp/nvim.log
nvim -V10/tmp/nvim.log
bat /tmp/nvim.log