Skip to content

Instantly share code, notes, and snippets.

@VonHeikemen
Created September 24, 2022 23:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save VonHeikemen/921556b7870b6135799c3b0fb8085974 to your computer and use it in GitHub Desktop.
Save VonHeikemen/921556b7870b6135799c3b0fb8085974 to your computer and use it in GitHub Desktop.
Separate NvChad's configuration from Neovim's default configuration
local path_sep = vim.loop.os_uname().version:match('Windows') and '\\' or '/'
local join = function(...) return table.concat({...}, path_sep) end
local getpath = function(arg)
local path = vim.fn.stdpath(arg)
return vim.fn.substitute(path, [[\(.*\)\zsnvim]], 'nvchad', '')
end
local user_path = getpath('config')
local data_path = getpath('data')
local chad_core = join(data_path, 'core', 'nvim')
vim.env.XDG_DATA_HOME = data_path
vim.env.XDG_CONFIG_HOME = join(data_path, 'core')
vim.env.XDG_CACHE_HOME = join(data_path, 'cache')
vim.env.XDG_STATE_HOME = join(data_path, 'state')
vim.opt.runtimepath = {
user_path,
chad_core,
vim.env.VIMRUNTIME,
join(chad_core, 'after'),
join(user_path, 'after'),
}
vim.opt.packpath = {
join(data_path, 'nvim', 'site'),
user_path,
vim.env.VIMRUNTIME
}
local execute = loadfile(join(chad_core, 'init.lua'))
if not execute then
vim.api.nvim_err_writeln("Could not load NvChad's init.lua")
return
end
execute()
@VonHeikemen
Copy link
Author

VonHeikemen commented Sep 25, 2022

Usage

Assuming you are using linux:

  • Clone NvChad in the same location the chad_core variable gives you.
git clone https://github.com/NvChad/NvChad ~/.local/share/nvchad/core/nvim
  • Create a configuration folder in the same location the user_path variable gives you.
mkdir -p ~/.config/nvchad
  • Copy the content of the gist in your config folder.
~/.config/nvchad/entry.lua
  • Make an alias that uses the new entry point.
alias nvchad='nvim -u ~/.config/nvchad/entry.lua'
  • Use the new command to open neovim with nvchad.
nvchad

To customize nvchad in this new setup create a lua module called custom in the configuration folder.

mkdir -p ~/.config/nvchad/lua/custom

Inside that new folder you can put your init.lua and the chadrc.lua.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment