-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·65 lines (49 loc) · 1.54 KB
/
Copy pathsetup.sh
File metadata and controls
executable file
·65 lines (49 loc) · 1.54 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
#!/bin/sh
set -eu
repo_dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
backup_path() {
path=$1
if [ -e "$path" ] || [ -L "$path" ]; then
mv "$path" "$path.backup.$(date +%Y%m%d%H%M%S)"
fi
}
link_path() {
source=$1
target=$2
if [ "$source" = "$target" ]; then
return
fi
if [ -L "$target" ] && [ "$(readlink "$target")" = "$source" ]; then
return
fi
if [ -L "$target" ]; then
rm "$target"
elif [ -e "$target" ]; then
backup_path "$target"
fi
ln -s "$source" "$target"
}
brew_install_if_missing() {
command_name=$1
formula=$2
if command -v "$command_name" >/dev/null 2>&1; then
return
fi
if command -v brew >/dev/null 2>&1; then
brew install "$formula"
else
echo "warning: $command_name not found; install $formula manually" >&2
fi
}
mkdir -p "$HOME/.config"
link_path "$repo_dir/nvim" "$HOME/.config/nvim"
brew_install_if_missing nvim neovim
brew_install_if_missing rg ripgrep
brew_install_if_missing tree-sitter tree-sitter-cli
brew_install_if_missing prettier prettier
brew_install_if_missing svelteserver svelte-language-server
brew_install_if_missing typescript-language-server typescript-language-server
if command -v nvim >/dev/null 2>&1; then
nvim --headless "+lua require('nvim-treesitter').install({ 'bash', 'c', 'css', 'go', 'html', 'javascript', 'json', 'lua', 'markdown', 'markdown_inline', 'python', 'query', 'rust', 'svelte', 'toml', 'tsx', 'typescript', 'vim', 'vimdoc', 'yaml' }):wait(300000)" +qa
fi
echo "Installed Neovim config: $HOME/.config/nvim -> $repo_dir/nvim"