How to install vim/neovim with Vdebug for xdebug debugging in Debian Stretch

I'm a big fan of:

  • the text editor Vim. It's super configurable and runs anywhere with a terminal.

  • the Debian operating system. It's rock solid, has a strong community and a fantastic package manager. It has never let me down.

  • the PHP Xdebug debugger which lets you halt a request mid process and inspect what's going on, step through code etc.

  • Vdebug which allows you to use Xdebug through Vim.

BUT! I've been upgrading my Debian servers from Jessie (8) to Stretch (9) and the sands have shifted. Stretch comes with Vim 8, which is great - I've been using a hand-compiled version of 8 for ages so it's lovely to have it packaged - but Debian has moved towards supporting Python 3 instead of the when-will-it-ever-die Python 2. Vim 8 brings some great improvements like async support which helps plugins work in a more responsive manor, but one drawback with Vim is that Python support, as with many many other features, has to be compiled in, and it can only support a single version of Python. All good so far, but Vdebug requires Python 2.

Neovim is a rewrite (basically) of Vim. It's still in alpha release stage, but it's trying to take all the greatness of Vim without 25 years' worth of baggage and bloat. It can support multiple Python versions. It's available in Stretch (v.0.1.7) but the Python integrations are only available in Sid.

Options: neovim, vim, vdebug, xdebug, python 2 or 3...

  • Use vim 8 from Stretch; wait for vdebug py3 compatibility.
    It looks like there's some effort going in on the vdebug github repo to port to Python 3, but it's no there yet and I can't wait.
  • compile vim8 on stretch with py2.
    I've done this for the last 18 monts or so, but Ug! I hate compiling packages. Getting the config right takes hours and then managing the install/uninstall is uncomfortable and can lead to zillions of files all over your system. Also you have to repeat the whole process if an upgrade breaks something.
  • use neovim and its py packages from Sid
    This worked! I downloaded the python-neovim and python3-neovim .deb files directly, installed with dpkg. All the dependencies could be satisfied from within Stretch's repos. I'm also shy of Apt "pinning" since it's very complex and can end up installing too many packages from unstable, so I was glad that I was able to do it this way. But I found a better way...

Solution: use neovim and use pip to install python support

All from Stretch, hooray. And it works!

sudo apt install neovim python-pip python3-pip
sudo pip install neovim
# Also get Python 3 support if needed with: sudo pip3 install neovim

Edit: prefer neovim from Sid

Neovim in Stretch reports that it has not been built optimally and therefore it 'will be slow'. I ask a lot of my editor and so slow frightens me. This is fixed in the unstable version, and luckily neovim has no dependencies, so it feels OK to install from sid. Here's how:

Install single package from unstable/sid in Debian stable/Stretch

I don't use the pinning method because it's waaay too complex. But there's a very simple method that Works For Me™:

% # Set the default release to Stretch.
% echo 'APT::Default-Release "stretch";' >/etc/apt/apt.conf.d/99defaultrelease
% # Add main Sid repo to sources.list
% grep 'stretch main' /etc/apt/sources.list | sed 's/stretch/sid/g' >>/etc/apt/sources.list 
% apt update
% apt install neovim/sid

 

Tags: 

Comments

Very helpful. I'm a longtime Vim user, but just getting started with Xdebug.  Also started using neovim a while ago and this is the first clearcut win I've seen for neovim vs vim. Thanks for taking the time to share this.

James Bridgewater replied on

Add new comment