-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·93 lines (78 loc) · 1.85 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·93 lines (78 loc) · 1.85 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
#!/bin/bash
set -Eeuo pipefail
NEOVIM_CONFIG="$HOME/.config/nvim"
NEOVIM_BACKUP="$NEOVIM_CONFIG.backup"
BACKUP_EXISTS=false
execute() {
echo "$*"
"$@"
}
log() {
printf 'INFO: %s\n' "$1"
}
err() {
printf 'ERROR: %s\n' "$1" >&2
}
restore_from_backup() {
trap - ERR
err "Something went wrong! Restoring Neovim config from backup..."
execute rm -rf "$NEOVIM_CONFIG"
execute mv "$NEOVIM_BACKUP" "$NEOVIM_CONFIG"
log "Successfully restored Neovim from backup. Exiting..."
}
failure() {
trap - ERR
err "Something went wrong! Exiting..."
}
if test -e "$NEOVIM_BACKUP"; then
err "A backup already exists at \`$NEOVIM_BACKUP\`. Move or delete it, then try again."
exit 1
fi
if test -e "$NEOVIM_CONFIG"; then
execute mv "$NEOVIM_CONFIG" "$NEOVIM_BACKUP"
BACKUP_EXISTS=true
trap restore_from_backup ERR
log "Successfully created backup of current Neovim config at $NEOVIM_BACKUP"
else
trap failure ERR
log "No preexisting Neovim config found. Continuing without backup..."
fi
# Runtimes the language servers are built/run with, the tools Telescope and
# conform.nvim shell out to, and the archive tools Mason needs to unpack packages.
pkgs=(
git
neovim
tree-sitter-cli
dotnet-sdk
go
npm
python
jdk21-openjdk
rust
tar
unzip
curl
ripgrep
fd
prettier
stylua
ruff
clang
)
log "Installing dependencies: ${pkgs[*]}"
execute sudo pacman -Sy --needed --noconfirm "${pkgs[@]}"
# Not packaged for Arch; conform.nvim formats shell scripts with it.
if command -v shuck >/dev/null 2>&1; then
log "shuck is already installed. Skipping..."
else
log "Installing shuck (shell formatter) with cargo"
execute cargo install shuck-cli
fi
log "Installing Neovim config"
execute git clone "https://github.com/borgaar/nvim" "$NEOVIM_CONFIG"
if $BACKUP_EXISTS; then
log "DONE! Backup of previous config is at $NEOVIM_BACKUP"
log "Exiting..."
else
log "DONE! Exiting..."
fi