Skip to content

Instantly share code, notes, and snippets.

@VonHeikemen
Last active October 3, 2023 11:36
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save VonHeikemen/1e82e8add1a5b9b2bdc767871af69514 to your computer and use it in GitHub Desktop.
Save VonHeikemen/1e82e8add1a5b9b2bdc767871af69514 to your computer and use it in GitHub Desktop.
Separate astronvim's configuration from Neovim's default.
--- For details of usage and explanation see:
--- https://dev.to/vonheikemen/how-to-install-astronvim-without-overriding-your-existing-neovim-configuration-1nke
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]], 'astronvim', '')
end
local data_path = getpath('data')
local astro_config = join(data_path, 'core')
local user_path = getpath('config')
vim.env.XDG_DATA_HOME = data_path
vim.env.XDG_CACHE_HOME = join(data_path, 'cache')
vim.env.XDG_STATE_HOME = join(data_path, 'state')
vim.opt.runtimepath = {
user_path,
astro_config,
vim.env.VIMRUNTIME,
join(astro_config, 'after'),
join(user_path, 'after'),
}
vim.opt.packpath = {
join(data_path, 'nvim', 'site'),
user_path,
vim.env.VIMRUNTIME
}
astronvim_installation = {home = astro_config}
local execute = loadfile(join(astro_config, 'init.lua'))
if not execute then
vim.api.nvim_err_writeln("Could not load AstroNvim's init.lua")
return
end
execute()
@VonHeikemen
Copy link
Author

VonHeikemen commented Sep 25, 2022

Usage

Assuming you are using linux:

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

To customize AstroNvim in this new setup create a lua module called user in the configuration folder.

mkdir -p ~/.config/astronvim/lua/user

Inside that new folder you create a file called init.lua. Check out this example configuration to know what you can do.

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