-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall-coc-nvim.sh
More file actions
executable file
·94 lines (79 loc) · 2.99 KB
/
install-coc-nvim.sh
File metadata and controls
executable file
·94 lines (79 loc) · 2.99 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
#!/usr/bin/env bash
set -o errexit # exit when command fails
# Script configuration
VIM_CONFIG_DIR="${HOME}/.vim"
VIM_PLUGINS_DIR="${VIM_CONFIG_DIR}/pack/plugins/start"
VIM_CONFIG_FILE="vimrc"
VIM_CONFIG_COC_FILE="vimrc-coc.vim"
COC_EXTENSIONS_DIR="${HOME}/.config/coc/extensions"
NVM_VERSION="v0.39.3"
MINIMUM_VIM_VERSION="8.1" # really 8.1.1719 (TODO)
if [ ! -x "$(command -v vim)" ]; then
echo 'Error: vim is not installed.' >&2
exit 1
fi
# Need curl for this script to be useful.
if [ ! -x "$(command -v curl)" ]; then
echo 'Error: curl is not installed.' >&2
exit 1
fi
no_node_error() {
echo 'Error: Install node via your system package manager or pass --install-nvm to install nodejs/nvm via nvm' >&2
echo 'Error: exiting until you install node.' >&2
if [ ! -z "${1}" ]; then
if [ "${1}" = "--install-nvm" ]; then
echo 'Info: Try: `nvm install --lts` then restarting your console session' >&2
echo 'Info: Re-run the script to intall coc-nvim' >&2
fi
fi
exit 1
}
# Install latest nodejs
if [ ! -x "$(command -v node)" ]; then
echo 'Error: node is not installed. It is required for coc-nvim' >&2
if [ ! -z "${1}" ]; then
if [ "${1}" = "--install-nvm" ]; then
curl -o- "https://raw.githubusercontent.com/nvm-sh/nvm/${NVM_VERSION}/install.sh" | bash
fi
else
no_node_error ${1}
fi
# Or use package manager, e.g.
# sudo apt-get install nodejs
else
# Use package feature to install coc.nvim
# for vim8
if [ ! -d "${VIM_PLUGINS_DIR}/coc.nvim-release" ]; then
(
cd "${VIM_PLUGINS_DIR}"
curl --fail -L https://github.com/neoclide/coc.nvim/archive/release.tar.gz | tar xzfv -
)
# for neovim
# mkdir -p ~/.local/share/nvim/site/pack/coc/start
# cd ~/.local/share/nvim/site/pack/coc/start
# curl --fail -L https://github.com/neoclide/coc.nvim/archive/release.tar.gz | tar xzfv -
fi
# Add a line at the end of the vimrc for coc-nvim to run correctly.
(
LINE="source ${VIM_CONFIG_DIR}/${VIM_CONFIG_COC_FILE}"
FILE="${VIM_CONFIG_FILE}"
cd ${VIM_CONFIG_DIR}
grep -qF -- "$LINE" "$FILE" || echo "$LINE" >> "$FILE"
)
fi
if [ ! -x "$(command -v npm)" ]; then
no_node_error ${1}
fi
# Install extensions
(
mkdir -p "${COC_EXTENSIONS_DIR}"
cd "${COC_EXTENSIONS_DIR}"
if [ ! -f package.json ]; then
echo '{"dependencies":{}}'> package.json
fi
# Change extension names to the extensions you need
npm install coc-markdownlint --install-stategy=shallow --ignore-scripts --no-bin-links --no-package-lock --omit=dev
npm install coc-clangd --install-stategy=shallow --ignore-scripts --no-bin-links --no-package-lock --omit=dev
npm install coc-pyright --install-stategy=shallow --ignore-scripts --no-bin-links --no-package-lock --omit=dev
npm install coc-json --install-stategy=shallow --ignore-scripts --no-bin-links --no-package-lock --omit=dev
)