-
-
Save siduck/048bed2e7570569e6b327b35d1715404 to your computer and use it in GitHub Desktop.
#!/bin/bash | |
# Run the script from home dir | |
cd ~ | |
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 | |
# 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" | |
# 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 |
I haven't done the migration yet, but the code is pretty big and has a lot going on. I already posted feedback about this (here), but I'll probably try to understand what it exactly does anyway and then see if I want to run it manually or not.
This script needs
set -e
at the top (or&&
or|| exit 1
on each step), so it won't continue if there are previous errors. I ran it, got a bunch of errors, and couldn't read the errors before nvim started. In hindsight I should have just done each step manually.
feel free to send an updated version of the script, i'll add it in the migration docs on nvchad.com itself
hi. I'm configure nvim-dap. In 2.0, it can be configured like (copied from here https://github.com/dreamsofcode-io/neovim-cpp/blob/main/plugins.lua#L33):
{
"mfussenegger/nvim-dap",
config = function(_, _)
require("core.utils").load_mappings("dap")
end
},
Migrate it into lua/plugins/xxx.lua in v2.5, it reports error:
Failed to run `config` for nvim-dap
/root/.config/nvim/lua/plugins/myplugins.lua:35: module 'core.utils' not found:
^Ino field package.preload['core.utils']
cache_loader: module core.utils not found
cache_loader_lib: module core.utils not found
^Ino file './core/utils.lua'
^Ino file '/__w/neovim/neovim/.deps/usr/share/luajit-2.1/core/utils.lua'
^Ino file '/usr/local/share/lua/5.1/core/utils.lua'
^Ino file '/usr/local/share/lua/5.1/core/utils/init.lua'
^Ino file '/__w/neovim/neovim/.deps/usr/share/lua/5.1/core/utils.lua'
^Ino file '/__w/neovim/neovim/.deps/usr/share/lua/5.1/core/utils/init.lua'
^Ino file './core/utils.so'
^Ino file '/usr/local/lib/lua/5.1/core/utils.so'
^Ino file '/__w/neovim/neovim/.deps/usr/lib/lua/5.1/core/utils.so'
^Ino file '/usr/local/lib/lua/5.1/loadall.so'
^Ino file './core.so'
^Ino file '/usr/local/lib/lua/5.1/core.so'
^Ino file '/__w/neovim/neovim/.deps/usr/lib/lua/5.1/core.so'
^Ino file '/usr/local/lib/lua/5.1/loadall.so'
# stacktrace:
- lua/plugins/myplugins.lua:35 _in_ **config**
Press ENTER or type command to continue
Failed to run `config` for nvim-dap-ui
/root/.local/share/nvim/lazy/nvim-dap-ui/lua/dapui/init.lua:36: nvim-dap-ui requires nvim-nio to be installed. Install from https://github.com/nvim-neotest/nvim-nio
How can I solve this ?
BTW, I install neovim 0.9.5 in customized path:
# ls /data/opt/nvim/
bin lib man share
@baiwfg2 the mapping part isnt automatic, so please remove the core.utils** stuff and convert your mappings to new ones
Works on macos with gsed in lieu of sed
This script needs
set -e
at the top (or&&
or|| exit 1
on each step), so it won't continue if there are previous errors. I ran it, got a bunch of errors, and couldn't read the errors before nvim started. In hindsight I should have just done each step manually.