-
Notifications
You must be signed in to change notification settings - Fork 3
/
install.sh
executable file
·160 lines (136 loc) · 4.01 KB
/
install.sh
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
#!/usr/bin/env bash
# Install paperbenni's Neovim.
COCLIST="${COCLIST:-}"
NVIMCMD=${nvimcmd:-nvim}
CURLCMD=${curlcmd:-curl}
# install coc package headless
cocinstall() {
echo "installing completion $1"
if ! grep -q "\"$1\":" "$HOME/.config/coc/extensions/package.json"; then
$NVIMCMD +"CocInstall -sync $1" +qall &>/dev/null
fi
}
# install vim-plug, coc and treesitter plugins
install_plugins() {
echo "installing all plugins"
$NVIMCMD +"PlugInstall" +"qall"
$NVIMCMD +"PlugClean" +qall
echo 'installing treesitter parsers'
$NVIMCMD +'silent! TSInstallSync all' +qall &> /dev/null
if
grep -i memtotal /proc/meminfo |
grep -o '[0-9]*' |
grep -Eq '[0-9]{7,}' &&
! command -v termux-setup-storage && ! [ -e /opt/google/cros-containers/ ]
then
echo "installing heavy stuff"
cocinstall coc-tabnine
cocinstall coc-flutter
cocinstall coc-java
cocinstall coc-json
cocinstall coc-vimlsp
cocinstall coc-tailwindcss
cocinstall coc-tsserver
cocinstall coc-tsdetect
else
echo "skipping heavy stuff"
fi
cocinstall coc-marketplace
cocinstall coc-sh
cocinstall coc-diagnostic
cocinstall coc-clangd
cocinstall coc-jedi
cocinstall coc-explorer
cocinstall coc-markdownlint
cocinstall coc-html
cocinstall coc-emmet
cocinstall coc-highlight
cocinstall coc-snippets
cocinstall coc-ltex
cocinstall coc-vimtex
}
install_plug() {
if ! [ -e ~/.local/share/nvim/site/autoload/plug.vim ]; then
echo "Installing vim-plug"
$CURLCMD -fLo ~/.local/share/nvim/site/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
fi
}
checkcommand() {
if ! command -v "$1"; then
echo "$1 not found, please install" 1>&2
exit 1
fi
}
check_nix_install() {
if ! command -v nix-env; then return 1; fi
if ! command -v pip2 && ! python2 -c "import neovim"; then
nix-env -i -E 'f: with import <nixpkgs> { }; (python2.withPackages(ps: [ ps.pynvim ] ))'
fi
if ! command -v pip3 && ! python3 -c "import neovim"; then
nix-env -i -E 'f: with import <nixpkgs> { }; (python3.withPackages(ps: [ ps.pynvim ] ))'
fi
if ! command -v "$NVIMCMD"; then
nix-env -i neovim
fi
if ! command -v npm; then
nix-env -i nodejs
fi
if ! command -v "$CURLCMD"; then
nix-env -i curl
fi
}
check_dependencies() {
checkcommand "$CURLCMD"
checkcommand npm
checkcommand node
# TODO notify nix people of this
checkcommand imosid
# TODO check node version
}
backup_config() {
cd || exit 1
mv .config/nvim .config/"$(date '+%y%m%d%H%M%S')"_nvim_backup 2>/dev/null
mkdir -p .config/nvim
mkdir -p .config/bat
}
install_cfg_files() {
echo "installing config files"
RAWHUB="https://raw.githubusercontent.com/paperbenni/nvim/main"
$CURLCMD -s "$RAWHUB/init.vim" >.config/nvim/init.vim
$CURLCMD -s "$RAWHUB/batconfig" >.config/bat/config
$CURLCMD -s "$RAWHUB/coc-settings.json" >.config/nvim/coc-settings.json
}
install_providers() {
echo "installing neovim providers"
for x in 2 3; do
if ! python$x -c "import neovim"; then
sudo pip$x install neovim pynvim
fi
done
if ! command -v nvim; then
if ! npm list -g | grep 'neovim'; then
sudo npm install -g neovim
fi
# TODO check for gem existance
if ! gem list | grep 'neovim'; then
sudo gem install neovim
fi
fi
}
main() {
echo "installing paperbenni's neovim config"
echo "warning, this will override existing configs"
# Keep what this function does distribution agnostic!
backup_config
install_plug
install_cfg_files
install_plugins
echo "finished installing paperbenni's neovim config"
}
if [ "$0" = "$BASH_SOURCE" ]; then
check_nix_install
check_dependencies
install_providers
main "$@"
fi