-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·113 lines (105 loc) · 3.34 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·113 lines (105 loc) · 3.34 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
#!/usr/bin/env sh
set -eu
repository="${WAVE_NVIM_REPOSITORY:-https://github.com/wavefnd/nvim-wave.git}"
app_name="${NVIM_APPNAME:-nvim}"
config_home="${XDG_CONFIG_HOME:-${HOME}/.config}"
data_home="${XDG_DATA_HOME:-${HOME}/.local/share}"
config_dir="${config_home}/${app_name}"
native_target="${data_home}/${app_name}/site/pack/wave/start/nvim-wave"
install_lsp=0
install_mode=auto
target=""
for argument in "$@"; do
case "${argument}" in
--with-lsp)
install_lsp=1
;;
--lazy)
install_mode=lazy
;;
--native)
install_mode=native
;;
--help|-h)
printf '%s\n' "usage: install.sh [--lazy|--native] [--with-lsp] [target]"
exit 0
;;
*)
if [ -z "${target}" ]; then
target=${argument}
else
printf '%s\n' "usage: install.sh [--lazy|--native] [--with-lsp] [target]" >&2
exit 2
fi
;;
esac
done
if [ -n "${target}" ]; then
if [ "${install_mode}" = "lazy" ]; then
printf '%s\n' "error: an explicit target cannot be combined with --lazy" >&2
exit 2
fi
install_mode=native
native_target=${target}
fi
if [ "${install_mode}" = "auto" ]; then
if [ -f "${config_dir}/lazy-lock.json" ] || [ -f "${config_dir}/lua/config/lazy.lua" ]; then
install_mode=lazy
else
install_mode=native
fi
fi
if ! command -v git >/dev/null 2>&1; then
printf '%s\n' "error: git is required" >&2
exit 1
fi
if [ "${install_mode}" = "lazy" ]; then
plugin_dir="${config_dir}/lua/plugins"
plugin_spec="${plugin_dir}/wave.lua"
if [ -f "${plugin_spec}" ]; then
if grep -Fq "wavefnd/nvim-wave" "${plugin_spec}"; then
printf '%s\n' "LazyVim configuration already exists at ${plugin_spec}"
else
printf '%s\n' "error: ${plugin_spec} already exists and was not created for wave.nvim" >&2
exit 1
fi
else
mkdir -p "${plugin_dir}"
printf '%s\n' \
'return {' \
' {' \
' "wavefnd/nvim-wave",' \
' event = { "BufReadPre *.wave", "BufNewFile *.wave" },' \
' opts = {},' \
' },' \
'}' > "${plugin_spec}"
printf '%s\n' "Created LazyVim configuration at ${plugin_spec}"
fi
if [ -d "${native_target}/.git" ]; then
printf '%s\n' "note: ${native_target} is a previous native install; LazyVim does not load it."
fi
printf '%s\n' "wave.nvim will be installed by lazy.nvim on the next Neovim start."
else
if [ -d "${native_target}/.git" ]; then
printf '%s\n' "Updating wave.nvim in ${native_target}"
git -C "${native_target}" pull --ff-only
elif [ -e "${native_target}" ]; then
printf '%s\n' "error: ${native_target} exists but is not a Git checkout" >&2
exit 1
else
printf '%s\n' "Installing wave.nvim into ${native_target}"
git clone "${repository}" "${native_target}"
fi
printf '%s\n' "wave.nvim native package is installed."
fi
if [ "${install_lsp}" -eq 1 ] && ! command -v wave-agape >/dev/null 2>&1; then
if ! command -v cargo >/dev/null 2>&1; then
printf '%s\n' "error: cargo is required to install wave-agape" >&2
exit 1
fi
printf '%s\n' "Installing wave-agape with Cargo"
cargo install --git https://github.com/wavefnd/wave-agape --tag v0.3.0 --locked
elif ! command -v wave-agape >/dev/null 2>&1; then
printf '%s\n' "note: wave-agape is not on PATH; install it for LSP features."
fi
printf '%s\n' "Open a .wave file, then run :checkhealth wave."