-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
72 lines (54 loc) · 1.77 KB
/
Copy pathsetup.sh
File metadata and controls
72 lines (54 loc) · 1.77 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
#!/usr/bin/env bash
EXCEPTION=('.gitignore' '.git' '.gitmodules' 'README.md' '.' '..' 'setup.sh' '.config')
BACKUP_FOLDER='.dotfiles_backup'
# Download Git submodules
cd "$HOME/.dotfiles"
git submodule init
git submodule update --remote || git submodule update --recursive
cd $HOME
# Select only the config files
REGEX=$(printf '%q|' "${EXCEPTION[@]}")
REGEX=${REGEX::-1}
REGEX="^($REGEX)$"
FILE_LIST=$(ls -a .dotfiles/ | egrep -v $REGEX)
# Backup conflicting config files
mkdir $BACKUP_FOLDER
mv $FILE_LIST $BACKUP_FOLDER 2>/dev/null
# Remove backup folder if empty
rmdir $BACKUP_FOLDER 2>/dev/null
# Create symlink
for filename in $FILE_LIST; do
ln -s ".dotfiles/$filename" .
done
##
## Vim configuration
##
# Add gopls for Go linting with ALE
GO111MODULE=on go get golang.org/x/tools/gopls@latest || echo 'Could not go get gopls. Go linting in Vim will not work optimally'
##
## .config configuration
##
mkdir -p "$HOME/.config"
CONFIG_FILES=$(ls -a .dotfiles/.config/ | egrep -v '^\.{1,2}$')
# Backup conflicting config files
for filename in $CONFIG_FILES; do
mv "$HOME/.config/$filename" "$HOME/$BACKUP_FOLDER" 2>/dev/null
done
# Create symlinks
for filename in $CONFIG_FILES; do
ln -s "$HOME/.dotfiles/.config/$filename" "$HOME/.config/$filename"
done
##
## Neovim dependency checks
##
has() { command -v "$1" >/dev/null 2>&1; }
echo
echo "Neovim optional dependencies:"
has gcc || echo " gcc → treesitter parser compilation"
has npm || echo " npm → pyright (Python LSP)"
has cargo || echo " cargo → rust_analyzer, rustfmt"
has python3 || echo " python3 → black, ruff"
has clang || echo " clang → clangd, clang-format"
{ has xclip || has wl-copy; } || echo " xclip/wl-copy → system clipboard"
echo
echo 'Environnement has been set up'