DEV Community

Hoon Wee
Hoon Wee

Posted on

Every Neovim, Every Config, All At Once

Neovim is hot 🔥 right now

Neovim, a successful fork of Vim, is a text editor that is gaining popularity. I won't link David Heinemeier Hansson's blog post again since everyone has done it already.

I also won't list all the good stuff about Neovim, since you can find them on the official website and tons of blog posts.

You can build your own IDE, or should I say, own IDEs(plural)

Just by learning a super-easy Lua language, you can build your own IDE with Neovim. If you're a busy person, you can just copy and paste someone else's config.

You can also find a fully-plugged IDE level config like:

All you have to do is to clone the repo and paste it in your ~/.config/nvim directory.

# Backup your current config
mv ~/.config/nvim ~/.config/nvim.bak

# Clone the repo
git clone <remote repo> ~/.config/nvim --depth 1

# Run neovim
nvim
Enter fullscreen mode Exit fullscreen mode

But what if you want to use multiple configs at the same time?

The answer is simple. All you need to set is the NVIM_APPNAME environment variable.

Example: Using LunarVim and NvChad at the same time

Let's say you want to use LunarVim for your web development and NvChad for your data science work.
You should first clone both repos with their custom directory names.

# Clone LunarVim
$ git clone git@github.com:LunarVim/LunarVim.git ~/.config/lunarvim --depth 1

# Clone NvChad
$ git clone https://github.com/NvChad/NvChad ~/.config/nvchad --depth 1

Enter fullscreen mode Exit fullscreen mode

Then, you can set the NVIM_APPNAME environment variable to use each config.

# Run neovim with LunarVim
$ NVIM_APPNAME=lunarvim nvim

# Run neovim with NvChad
$ NVIM_APPNAME=nvchad nvim
Enter fullscreen mode Exit fullscreen mode

You can still use the default config by just running nvim without setting the NVIM_APPNAME environment variable. (This reads the config from ~/.config/nvim)

# Run neovim with the default config
$ nvim
Enter fullscreen mode Exit fullscreen mode

Example: Make aliases for each config

You can also make aliases for each config.

# Add these lines to your .bashrc or .zshrc

alias lunarvim="NVIM_APPNAME=lunarvim nvim"
alias nvchad="NVIM_APPNAME=nvchad nvim"

# Run neovim with LunarVim
$ lunarvim
Enter fullscreen mode Exit fullscreen mode

Conclusion

That's it! You can use multiple Neovim configs at the same time, with just a simple environment variable NVIM_APPNAME.

Now, some might say "Why don't you just use Docker?". Well, not everyone is comfortable with Docker, and since Neovim just supports this feature, why not use it?

I hope this tip helps you to use Neovim more effectively. Happy hacking! 🚀

Top comments (0)