Repository navigation
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·114 lines (94 loc) · 2.47 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·114 lines (94 loc) · 2.47 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
114
#!/bin/bash
set -e
# colors
red='\033[0;31m'
green='\033[0;32m'
yellow='\033[0;33m'
nc='\033[0m'
info() { echo -e "${green}[*]${nc} $1"; }
warn() { echo -e "${yellow}[!]${nc} $1"; }
error() { echo -e "${red}[x]${nc} $1"; exit 1; }
# check neovim version
check_nvim() {
if ! command -v nvim &> /dev/null; then
error "neovim not found. install neovim 0.11+ first."
fi
version=$(nvim --version | head -n1 | grep -oP '\d+\.\d+')
major=$(echo "$version" | cut -d. -f1)
minor=$(echo "$version" | cut -d. -f2)
if [ "$major" -lt 1 ] && [ "$minor" -lt 11 ]; then
error "neovim 0.11+ required, found $version"
fi
info "neovim $version found"
}
# backup existing config
backup_config() {
if [ -d ~/.config/nvim ]; then
if [ -d ~/.config/nvim/.git ]; then
warn "existing nvim config is a git repo, skipping backup"
return 1
fi
backup_dir=~/.config/nvim.backup.$(date +%s)
warn "backing up existing config to $backup_dir"
mv ~/.config/nvim "$backup_dir"
fi
return 0
}
# clone config
clone_config() {
info "cloning config..."
git clone git@github.com:vmfunc/nvim.git ~/.config/nvim
}
# install dependencies (arch)
install_deps_arch() {
info "installing dependencies (arch)..."
sudo pacman -S --needed --noconfirm ripgrep fd lazygit
}
# install dependencies (debian/ubuntu)
install_deps_debian() {
info "installing dependencies (debian/ubuntu)..."
sudo apt update
sudo apt install -y ripgrep fd-find
# lazygit from github
if ! command -v lazygit &> /dev/null; then
warn "lazygit not in apt, install manually from https://github.com/jesseduffield/lazygit"
fi
}
# install dependencies (macos)
install_deps_macos() {
info "installing dependencies (macos)..."
brew install ripgrep fd lazygit
}
# detect os and install deps
install_deps() {
if [ -f /etc/arch-release ]; then
install_deps_arch
elif [ -f /etc/debian_version ]; then
install_deps_debian
elif [[ "$OSTYPE" == "darwin"* ]]; then
install_deps_macos
else
warn "unknown os, install ripgrep, fd, lazygit manually"
fi
}
main() {
echo ""
echo " nvim config installer"
echo " ====================="
echo ""
check_nvim
if backup_config; then
clone_config
else
info "using existing config directory"
fi
read -p "install dependencies? (ripgrep, fd, lazygit) [y/N] " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
install_deps
fi
echo ""
info "done! run 'nvim' to start. plugins will install automatically."
echo ""
}
main