-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnvchad_migrate.sh
executable file
·52 lines (35 loc) · 1.38 KB
/
nvchad_migrate.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
#!/bin/bash
# Run the script from home dir
cd ~ || exit 1
nvim_config="$HOME/.config/nvim"
nvim_data="$HOME/.local/share/nvim"
cp -r "$nvim_config" nvim_bak # backup nvim dir
cp -r "$nvim_config/lua/custom" .
# Remove prefix 'custom.' from all files
find custom -type f -exec sed -i 's/custom\.//g' {} +
# replace all plugins.configs -> nvchad.configs
find custom -type f -exec sed -i 's/plugins.configs/nvchad.configs/g' {} +
cd custom || exit 1
# we will load this in main init.lua
mv init.lua myinit.lua
# disable these fields in chadrc
sed -Ei 's/M.mappings|M.plugins/-- &/g' chadrc.lua
# add new module paths
[ -e options.lua ] && sed -i '1s/^/require "nvchad.options"\n/' options.lua
[ -e autocmds.lua ] && sed -i '1s/^/require "nvchad.autocmds"\n/' autocmds.lua
[ -e mappings.lua ] && sed -i '1s/^/require "nvchad.mappings"\n/' mappings.lua
cd ..
rm -rf "$nvim_config" "$nvim_data"
# setup new config
git clone https://github.com/NvChad/starter "$nvim_config"
if [ -e custom/configs ]; then
mv custom/configs/* "$nvim_config/lua/configs/"
rm -rf custom/configs
fi
mv custom/* "$nvim_config/lua"
cd "$nvim_config" || exit 1
# load custom.init.lua if it exists
[ -e lua/myinit.lua ] && echo "require 'myinit'" >> init.lua
# Some users have plugins.lua instead of plugins dir/ so move it in the plugins dir
[ -e lua/plugins.lua ] && mv lua/plugins.lua lua/plugins/myplugins.lua
nvim