vim with lua

This is a log of the steps I took to compile vim with lua support. I wrapped everything up in a script that I called ‘luavim’. I have tested it on CentOS/RedHat, Debian/Ubuntu and Alpine Linux.

Dependencies are:
Libraries: libreadline, libcurses, glibc/musl
Packages: git, gcc, make

To install the dependencies for Alpine Linux, you can run:

# apk add musl-dev git gcc make readline-dev ncurses-dev

To install the dependencies for Debian/Ubuntu, you can run:

# apt install gcc make libreadline-dev libncurses-dev

To install the dependencies for CentOS/RedHat, you can run:

# yum install git gcc make readline-devel ncurses-devel

Everything gets installed into /usr/local. The user running this script must have sudo.

This is the script:

#!/bin/sh

operator=$(whoami)
srcdir=/opt/src

main() {

   if [ -z $1 ]
   then
      usage
   fi

   init

   case "$1" in
      a) buildlua; buildvim ;;
      l) buildlua ;;
      v) buildvim ;;
      r) reset ;;
      *) echo "invalid"; usage ;;
   esac
}

init() {
   if [ ! -d ${srcdir} ]
   then
      sudo mkdir -pv ${srcdir}
   fi
   sudo chown -R ${operator} ${srcdir}
}

buildlua() {

   cd ${srcdir}
   if [ ! -d lua ]
   then
      echo "Cloning github lua repository..."
      git clone https://github.com/lua/lua.git
   fi

   cd ${srcdir}/lua
   make clean
   git pull
   sudo make uninstall

   make linux -j 4
   sudo make install

   lua -v

}

buildvim() {

   cd ${srcdir}
   if [ ! -d vim ]
   then
      echo "Cloning github lua repository..."
      git clone https://github.com/vim/vim.git
   fi
   
   cd ${srcdir}/vim
   make clean
   git pull

   ./configure 
   --with-compiledby=lyderic 
   --with-features=huge 
   --enable-luainterp 
   --with-lua-prefix=/usr/local 
   --enable-fail-if-missing

   sudo make uninstall
   make -j 4
   sudo make install

}

reset() {
   cd ${srcdir}/lua
   sudo make uninstall
   cd ${srcdir}/vim
   sudo make uninstall
   sudo rm -rfv ${srcdir}
}

usage() {
   echo "Usage: $(basename $0) "
   echo "Actions:"
   echo " a  build lua and vim"
   echo " l  build lua only"
   echo " v  build vim only"
   echo " r  wipes everything"
   exit 2
}

main $@
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s