My OCaml development environment in Debian has been working well since I set it up. In this post I talk about setting up Merlin in vim and neovim. See this discussion for other well-liked OCaml environment set up. I’ve been using neovim and I like it so I’ll stick with this for now.
Setting Up Merlin in Vim
First, Merlin has to be installed. Installing Merlin using OPAM was smooth and easy. I just ran
opam install merlin
and it worked. Then, because I want to use it in vim, I need to put the following in vimrc to add Merlin to the runtime path (see this guide):
let g:opamshare = substitute(system('opam config var share'),'\n$','','''') execute "set rtp+=" . g:opamshare . "/merlin/vim"
Run :so .vimrc in your home directory (or wherever your vimrc is) in vim to make vim see the .vimrc changes. After this, Merlin works in vim! I can call Merlin commands like :MerlinErrorCheck in vim!
Setting Up Merlin in Neovim
However, it only works in plain vim but not neovim. I prefer neovim to vim because, among other reasons, it has a cleaner code base than vim. To get Merlin working in neovim, I need the python-neovim and python3-neovim packages. The problem is, neither of the python packages are in Debian Stretch (stable), the version of Debian I’m in. However, they are in Debian Buster (testing).
So I proceed by following this link. I temporarily told my Debian to grab software from the testing version source list:
- Edit the “etc/apt/sources.list” file, changing the source from stable to testing.
- Run apt update to get the new source list.
- Grab the python-neovim and python3-neovim packages using apt. (Run apt install python-neovim python3-neovim)
- Revert the “etc/apt/sources.list” file, changing the source from testing back to stable.
- Run apt update again to get the source list from stable again.
The next thing I know, I couldn’t log back into my computer after I came back from lunch! Apparently I uninstalled my display manager and window manager in the above process! What happened was that when I installed the python packages, apt, working on the assumption that I was on testing, noticed some packages were no longer needed. I ran apt autoremove to remove them, and removed packages that I needed! I should have been more careful about removing packages.
Anyway, I’m now on Debian Buster, with Merlin working in my neovim! I hope the testing version of Debian is not too unstable for me. I’ll let you know!
Leave a Reply