-
Notifications
You must be signed in to change notification settings - Fork 5
/
fetch-nvim-conf.sh
executable file
·66 lines (56 loc) · 2 KB
/
fetch-nvim-conf.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
#!/bin/bash
if grep Ubuntu /etc/os-release; then
echo "Ubuntu is not supported for now." # maybe someday
exit 1
else
pacman --version || exit 1
# packages from arch repo
PKG=(autopep8 ansible-lint neovim go npm rust-analyzer lua-language-server fd ripgrep xclip rsync python-virtualenv wget)
# chech all packages if installed
# to avoid asking for sudo if nothing will be installed
TO_INSTALL=()
for pn in "${PKG[@]}"; do
pacman -Q | grep "$pn " || TO_INSTALL+=("$pn")
done
# install all at once
[ "${#TO_INSTALL[@]}" -eq 0 ] || sudo pacman -Sy --noconfirm --needed "${TO_INSTALL[@]}"
fi
mkdir -p ~/.config/nvim
mkdir -p ~/.node_modules/lib/node_modules
git clone --depth=1 https://github.com/coffebar/dotfiles.git /tmp/dotfiles_tmp_nvim
rsync -rv --delete /tmp/dotfiles_tmp_nvim/.config/nvim/ ~/.config/nvim/
rm -rf /tmp/dotfiles_tmp_nvim/
npm config set prefix ~/.node_modules
# install pnpm for better performance and disk space usage
npm install -g pnpm
# set pnpm home env variable
export PNPM_HOME=~/.local/share/pnpm
# if pnpm is not in PATH, add it
if ! command -v pnpm > /dev/null; then
export PATH="$PATH:$HOME/.local/share/pnpm:$HOME/.node_modules/bin"
fi
_INSTALLED=$(pnpm list -g)
function install_nodejs_packages_if_needed() {
# install packages if not installed
for p in "$@"; do
echo "$_INSTALLED" | grep -F "$p " > /dev/null || pnpm install -g "$p"
done
}
install_nodejs_packages_if_needed pyright bash-language-server \
@ansible/ansible-language-server \
vscode-langservers-extracted \
prettier prettier-plugin-ssh-config \
prettier-plugin-sh \
prettier-plugin-nginx @prettier/plugin-php \
typescript typescript-language-server \
stylefmt intelephense \
tree-sitter-cli \
eslint @johnnymorganz/stylua-bin \
@shufo/prettier-plugin-blade \
emmet-ls \
neovim \
@vue/language-server @vue/typescript-plugin
go install golang.org/x/tools/gopls@latest
# download stubs for LSP, currently only for PHP
source ~/.config/nvim/download-stubs.sh
nvim --headless "+Lazy! sync" +qa > /dev/null 2>&1