-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathinstall_lazyvim.sh
executable file
·131 lines (110 loc) · 3.55 KB
/
install_lazyvim.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
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#!/bin/bash
DIR="$(
cd "$(dirname "$(readlink -f "$0")")" || exit
pwd -P
)"
install_first_time() {
# NOTE: This only needs to be run once
# Backup lazyvim
# - only the first is required; remains are optional but recommended
for f in ~/.config/nvim ~/.local/share/nvim ~/.local/state/nvim ~/.cache/nvim ; do
if [ -e $f ] ; then
echo mv $f $f.bak
fi
done
TARGET="$DIR/../../configs/lazynvim"
git clone https://github.com/LazyVim/starter "$TARGET"
ln -s "$TARGET" ~/.config/nvim
rm -rf $TARGET/.git
# TODO: manually commit the changes to your repo
TARGET="$DIR/../../configs/lazynvim"
cd $TARGET
ln -s ../nvim/luasnip_snippets .
# TODO: manually commit the symlink to your repo
}
install_lazyvim() {
# Backup lazyvim
# - only the first is required; remains are optional but recommended
for f in ~/.config/nvim ~/.local/share/nvim ~/.local/state/nvim ~/.cache/nvim ; do
if [ -e $f ] ; then
echo mv $f $f.bak
fi
done
# link the lazyvim config
TARGET="$DIR/../../configs/lazynvim"
ln -s "$TARGET" ~/.config/nvim
}
install_lazygit() {
APP_DIR="$HOME/apps/lazygit"
mkdir -p $APP_DIR
cd $APP_DIR
LAZYGIT_VERSION=$(curl -s "https://api.github.com/repos/jesseduffield/lazygit/releases/latest" | grep -Po '"tag_name": "v\K[^"]*')
curl -Lo lazygit.tar.gz "https://github.com/jesseduffield/lazygit/releases/latest/download/lazygit_${LAZYGIT_VERSION}_Linux_x86_64.tar.gz"
tar xf lazygit.tar.gz lazygit
ln -s $APP_DIR/lazygit ~/bin/
}
link_conf() {
# TODO: will it work?
ln -s ~/deploy/configs/shell/style.yapf ~/.style.yapf
ln -s ~/deploy/configs/lazynvim/stylua.toml ~/.config/
}
install_or_update_neovim_app() {
if ! which pip ; then
# 第一次安装可能还没有配置好自动 source .bashrc/.zshrc
. ~/miniconda3/etc/profile.d/conda.sh
conda activate base
fi
pip install debugpy # this will used by nvim-dap
# generate a redable unique string based on datetime
NAME="nvim-latest-$(date +%Y%m%d%H%M%S)"
curl -L -o ~/bin/$NAME https://github.com/neovim/neovim/releases/latest/download/nvim.appimage
chmod a+x ~/bin/$NAME
for target in vim nvim; do
if [ -e ~/bin/$target ] ; then
unlink ~/bin/$target
fi
ln -s ~/bin/$NAME ~/bin/$target
done
}
build_from_source() {
# For legacy system with glibc 2.27, we have to build from source
# - https://www.reddit.com/r/neovim/comments/1cxdf1i/nvim_appimagerelease_tarballs_not_working_on/
# this for vim with old version.
sudo apt-get install -y gettext
APP_PATH=~/apps/nvim-source
mkdir -p $APP_PATH
cd ~/apps/nvim-source
wget https://github.com/neovim/neovim/archive/refs/tags/stable.tar.gz
tar xf stable.tar.gz
cd neovim-stable
make CMAKE_BUILD_TYPE=RelWithDebInfo CMAKE_INSTALL_PREFIX=$APP_PATH
make install
for target in vim nvim; do
if [ -e ~/bin/$target ] ; then
unlink ~/bin/$target
fi
ln -s $APP_PATH/bin/nvim ~/bin/$target
done
}
merge_previous_config() {
# TODO: link previous snippets
echo TODO
}
deploy() {
sudo apt-get install -y libfuse2 xsel
# - libfuse2: https://askubuntu.com/a/1451171
# - xsel: https://github.com/tmux-plugins/tmux-yank to support copying in tmux and the system clipboard
# MobaXterm can support bi-directional clipboard between remote and local
# nodejs is necessary for language servers
deploy_apps/deploy_nodejs.sh
deploy_apps/install_rg.sh
# - frequently used by nvim
install_or_update_neovim_app
install_lazyvim
install_lazygit
link_conf
}
# default install_first_time otherwise the argument
# CMD=${1:-install_first_time}
# $CMD
$1