DEV Community

Karl N. Redman
Karl N. Redman

Posted on • Updated on • Originally published at github.com

Compile and install vim 8.1 from source (debian / MX Linux) with pyenv

Install and setup pyenv

pyenv provides a localized python, versioned, installation at the user level.

curl https://pyenv.run | bash
  • config: add to your ~/.bashrc file and relogin (terminal or desktop env)
# Load pyenv automatically by adding
# the following to ~/.bashrc:

export PATH="/home/karl/.pyenv/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
  • install a python version
# list available versions
pyenv install -l |less
# insta a version
pyenv install 3.7.2
  • set a python version for global
pyenv global 3.7.2

Script for vim compile and installation

#! /usr/bin/env bash

# Install vim from source on a debian based system where pyenv is used at thhe user level.
## The python version must already be installed via pyenv
## `pyenv install 3.7.2`
## It is not necessary remove debian installed vim packages


# fail on any error (fix things as needed)
set -e

# Convenience variables
FULL_VERSION="3.7.2"
MM_VERSION="3.7"
VIM_CONENSED_VER="81"
VIM_TAG="v8.1"
BUILT_BY="Karl N. Redman <karl.redman@gmail.com>"

# Install dependencies (note no python-dev here)
sudo apt install -y libncurses5-dev libgnome2-dev libgnomeui-dev \
libgtk2.0-dev libatk1.0-dev libbonoboui2-dev \
libcairo2-dev libx11-dev libxpm-dev libxt-dev \
ruby-dev lua5.1 liblua5.1-dev libperl-dev git

# Checkout vim
git clone https://github.com/vim/vim.git
cd vim

# make sure the repo is clean
make distclean

# (optional) Checkout the specific desired version
## umcomment to use specific tagged version
# git pull --tags
# git checkout tags/${VIM_TAG}

# Run `Configure`
./configure --with-features=huge \
            --enable-multibyte \
            --enable-rubyinterp=yes \
            --with-x \
            --enable-perlinterp=yes \
            --enable-luainterp=yes \
            --enable-gui=gtk2 \
            --enable-cscope \
            --prefix=/usr/local \
            --with-compiledby="${BUILT_BY}" \
            --enable-python3interp=yes \
            --with-python3-config-dir=$HOME/.pyenv/versions/${FULL_VERSION}/lib/python${MM_VERSION}/config-${MM_VERSION}m-x86_64-linux-gnu \
            --includedir=$HOME/.pyenv/versions/${FULL_VERSION}/include/

# Make and set the runtime directory (non default to avoid conflicts)
make VIMRUNTIMEDIR=/usr/local/share/vim/vim${VIM_CONENSED_VER}

## (optional) uncomment to remove current vim if desired
# sudo apt remove -y vim vim-runtime gvim vim-tiny vim-common vim-gui-common vim-nox

# install (to usr local)
sudo make install

# update alternatives to set our new build as default
sudo update-alternatives --install /usr/bin/editor editor /usr/local/bin/vim 1
sudo update-alternatives --set editor /usr/local/bin/vim
sudo update-alternatives --install /usr/bin/vi vi /usr/local/bin/vim 1
sudo update-alternatives --set vi /usr/local/bin/vim

echo "done."

That's it!

  • relogin (if necessary) and vim --version should report v8.1! Now you can try out :terminal to make sure it's working ... and take advantage of the new plugins that are a comming!

Top comments (1)

Collapse
 
soyferrero profile image
soyFerrero

I change this..
/config-${MM_VERSION}m-x86_64-linux-gnu /

for this:
config-${MM_VERSION}-x86_64-linux-gnu/

In the version 3.8.0 of Python

And work for me

Great Job!!!