Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Best protip I heard about (n)vim customization: use git branches when you want to switch between different configurations. Eg something like:

- vanilla/default

- minimal

- fancy

depending on what you want to deal with. If I go months between using all these plugins I forget what they do and what changed and it’s just noisy distractions that invariably lead me to open my init.lua file rather than what I actually had intended to work on



I had luck using gnu stow to switch configs easily too.


Hadn’t heard of this. Thanks. I guess there are probably plenty of little GNU utilities out there that just haven’t hit their deserved mindshare yet



you can also use $NVIM_APPNAME if you want a more "full" switch between configurations. especially helpful for trying/switching between distributions (i use it for switching between my own config and lazyvim). basically, it modifies the paths where neovim looks for config and data files on startup:

config path: $XDG_CONFIG_HOME/nvim/ -> $XDG_CONFIG_HOME/$NVIM_APPNAME/

data path on Windows: $LOCALAPPDATA/nvim-data/ -> $LOCALAPPDATA/{$NVIM_APPNAME}-data/

https://neovim.io/doc/user/starting.html#%24NVIM_APPNAME


Why not stay in the editor and use `:source`?


what do you mean "use Git branches"?


Since the configuration is done in (dot)files you can version and track them with git. If you want several setups you could have them in branches and just ´git checkout X´ in your .vim or .config/nvim directory to change it and it would affect settings and plugins (as they're also just files).

I don't need it but I can see the use. I do have a dotfiles repository however it's very common in Linux and Mac, don't know about Windows. If I setup a new machine or spin up a VM I just have to clone that repository to have all my configurations for everything (even addons for Firefox and Chrome).

This article[1] is a good starting point if you want to try it out.

[1] https://www.atlassian.com/git/tutorials/dotfiles




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: