1. 14
  1. 6

    The biggest obstacle that I found to coexistence is that NeoVim uses the same name mangling / extension for undo files as Vim, but changed the format. If you’re using persistent undo in Vim (I do a lot, it’s one of my favourite features) then opening a file in nvim will trash its undo history unless you are careful to configure NeoVim to use a different location to store undo files.

    1. 1

      Could I bother you to share info on configuring separate persistent undo file names in nvim and vim, please? I keep meaning to enable persistent undo, but this scares me a little now in terms of transitioning from only vim to primarily nvim

      1. 3

        This is what I have:

        if has("nvim")
            set undodir=${XDG_CACHE_HOME}/nvim/undo//
            set dir=${XDG_CACHE_HOME}/nvim/swap//
            set backupdir=${XDG_CACHE_HOME}/nvim/backup//
        else
            set undodir=${XDG_CACHE_HOME}/vim/undo//
            set dir=${XDG_CACHE_HOME}/vim/swap//
            set backupdir=${XDG_CACHE_HOME}/vim/backup//
        endif
        set undofile
        set undolevels=1000
        set undoreload=10000
        

        I’m not actually using Neovim, because vim + ALE does everything I want. I tried neovim briefly but failed to set up TreeSitter into a useful state, but I think this was enough to stop nvim breaking vim. To be honest, the reaction I got from the NeoVim developers on this POLA violation put me off NeoVim (it basically boiled down to ‘this feature in Vim that you’ve been using for years doesn’t work very well so you shouldn’t rely on it and the fact that we broke it doesn’t matter’). It would have been trivial for NeoVim to change the name mangling of the undo file when they changed the format but they don’t seem to care about their users losing data, which is the opposite attitude I want from the people that write the tool that I use the most.

        This also moves swap files and backup files into a separate tree in ~/.cache/[n]vim, so I don’t need git and other tools to ignore the files, they just don’t clutter up my FS at all. The down side is that they don’t get deleted when I delete the associated files. The VM on which I’ve been doing most of my active development for the last 4 years has a 20M ~/.cache/vim, so I’m not really worried (13M undo, 5.4M backup). I remember when that would have been 50% of my hard disk capacity and I’m very happy to be living in the future.

        1. 1

          Sure! With my current setup is quite easy. I added a new value in only_vim.vim and it will be set a different backup folder when using vim. You can see the commit here.

          If you want some peace of mind, you can verify that they are different running :set undodir?

        2. 1

          I understand your problem, I have suffered it a couple of times. Normally it doesn’t bother me because I have “Neovim machines” or “Vim machines”. However, it is a good improvement suggestion to keep different location for the undo files.

        3. 2

          Oh hey a Booking.com person 🤗

          I tried to make neovim happen on the remote servers while I was there but couldn’t. Too much legacy. I think for that reason my .vimrc has stayed vim script for the last years with such little plugins.

          1. 2

            Hi fellow colleague! :D

            I also gave it a try and managed to get it working in some servers, but I still needed a solution for the most restricted ones. I wanted to try the new goodies but I didn’t want to break my whole flow so this is the result after a non trivial amount of hours. I hope it can help you and other people to give a try to the new stuff that is coming.

          2. 2

            I had this as an implied goal when I switched to neovim a few years ago, but tbqh I’ve been drifting further and further from it and since 0.5.x it’s just been a non-goal and I’m considering rewriting all my configuration in lua now, we’ll see.

            I’ve still made a point of keeping my unadorned vim skills intact enough that I can f.ex navigate tabs etc with out of the box bindings, but most of my development has been on a local machine at work lately so the benefit of a complex portable setup is minimal. Sounds like a great idea for your use case though!

            On a related note, been more and more pleased with the extras that nvim offers, especially the integrated language client. Impressed that the project has maintained steam so far!