LoginSignup
3
6

More than 5 years have passed since last update.

WSLにVim8を入れてみる

Last updated at Posted at 2018-01-27

WSL(Ubuntu)に入っているデフォルトのVimはVersion7.4です。
またVimのオプションでLuaが有効になっていないので入力補完のプラグイン(neocomplete.vim)
が使えません。

$ vim --version | grep lua
+dialog_con -lua

というわけで今回はWSLのVimをVim8+luaに置き替えたいと思います。
以下を参考させて頂きました。

Vimを削除

$ sudo apt-get remove --purge vim vim-runtime vim-common

コンパイルに必要なものを入れる

sudo apt-get install gcc-4.9 autoconf automake make lua5.3 luajit liblua5.3-0 liblua5.3-dev libperl5.22 libperl-dev libpython-dev python-dev python3-dev tcl tcl-dev

ソースからコンパイル&インストール

$ cd /usr/local/src/
$ sudo chmod a+w .
$ git clone https://github.com/vim/vim.git
$ cd vim
$ ./configure --with-features=huge \
>               --disable-darwin \
>               --disable-selinux \
>               --enable-fail-if-missing \
>               --enable-luainterp \
>               --enable-perlinterp=dynamic \
>               --enable-pythoninterp \
>               --enable-python3interp \
>               --enable-tclinterp \
>               --enable-cscope \
>               --enable-multibyte \
>               --enable-xim \
>               --enable-fontset \
>               --with-compiledby=xxxkurosukexxx \
>               --enable-gui=no \
>               --prefix=/usr/local

省略

checking for lua... no
checking if lua.h can be found in /usr/include... no
checking if lua.h can be found in /usr/include/lua... no
configure: error: could not configure lua
$

なんか怒られました。
luaがない??

いろいろと探してこれでいけました。
以下ページのJohanTanさんのコメントで行けた気がします。。。
Versionは適時自分の環境のものに読み替えてください。

こうするとのこと
sudo apt-get install liblua5.1-dev
copy all files from /usr/include/lua5.1/ to /usr/include/lua5.1/include/
sudo ln -s /usr/lib/x86_64-linux-gnu/liblua5.1.so /usr/local/lib/liblua.so
Go to vim source folder:
./configure --with-features=huge --enable-cscope --enable-pythoninterp=yes --with-python-config-dir=/usr/lib/python2.7/config-x86_64-linux-gnu --enable-multibyte --enable-fontset --disable-gui --disable-netbeans --enable-luainterp=yes --with-lua-prefix=/usr/include/lua5.1 --enable-largefile
make
sudo make install

実際の手順

includeフォルダを作成してコピー
/usr/include/lua5.3/include$ ls
lauxlib.h  lua  luaconf.h  lua.h  lua.hpp  lualib.h

シンボリックリンクを張る
$ sudo ln -s /usr/lib/x86_64-linux-gnu/liblua5.3.so /usr/local/lib/liblua.so

コンパイル
$ ./configure --with-features=huge \
>               --disable-darwin \
>               --disable-selinux \
>               --enable-fail-if-missing \
>               --enable-luainterp \
>               --with-lua-prefix=/usr/include/lua5.3 \
>               --enable-perlinterp=dynamic \
>               --enable-pythoninterp \
>               --enable-python3interp \
>               --enable-tclinterp \
>               --enable-cscope \
>               --enable-multibyte \
>               --enable-xim \
>               --enable-fontset \
>               --with-compiledby=xxxkurosukexxx \
>               --enable-gui=no \
>               --prefix=/usr/local
configure: loading cache auto/config.cache
checking whether make sets $(MAKE)... yes
checking for gcc... gcc
checking whether the C compiler works... yes
省略
checking whether we need -D_FORTIFY_SOURCE=1... yes
checking linker --as-needed support... yes
configure: updating cache auto/config.cache
configure: creating auto/config.status
config.status: creating auto/config.mk
config.status: creating auto/config.h

makeします。
$ make
Starting make in the src directory.
If there are problems, cd to the src directory and run make there
cd src && make first
make[1]: Entering directory '/usr/local/src/vim/src'
/bin/sh install-sh -c -d objects
touch objects/.dirstamp
省略
cd xxd; CC="gcc" CFLAGS=" -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1" LDFLAGS="-Wl,-E   -L/usr/local/lib -Wl,--as-needed" \
        make -f Makefile
make[2]: Entering directory '/usr/local/src/vim/src/xxd'
gcc  -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -Wl,-E   -L/usr/local/lib -Wl,--as-needed -DUNIX -o xxd xxd.c
make[2]: Leaving directory '/usr/local/src/vim/src/xxd'
make[1]: Leaving directory '/usr/local/src/vim/src'

install
$ sudo make install
Starting make in the src directory.
If there are problems, cd to the src directory and run make there
cd src && make install
make[1]: Entering directory '/usr/local/src/vim/src'
省略
if test -d /usr/local/share/applications -a -w /usr/local/share/applications; then \
   cp ../runtime/vim.desktop \
        ../runtime/gvim.desktop \
        /usr/local/share/applications; \
   if test -z "" -a -x ""; then \
       -q /usr/local/share/applications; \
   fi \
fi
make[1]: Leaving directory '/usr/local/src/vim/src'

入りましたー

キャプチャ.PNG

$ vim --version | grep lua
+cursorshape       +lua

dein.vimを入れる

最後にプラグイン管理ツールを入れます。
NeoBundleではなく後継のdein.vimを入れました。

手順は公式ページに従いました。

$ curl https://raw.githubusercontent.com/Shougo/dein.vim/master/bin/installer.sh > installer.sh
$ sh ./installer.sh .vim/bundle/dein

vimrcに以下のように記載しました。
tomlファイルはまだうまく使えていないです。。。

if &compatible
  set nocompatible
endif
set runtimepath+=/home/xxx/.vim/bundle/dein/repos/github.com/Shougo/dein.vim

let s:dein_dir = expand('~/.vim/bundle/dein')

if dein#load_state(s:dein_dir)
  call dein#begin(s:dein_dir)

  call dein#add('Shougo/deoplete.nvim')
  if !has('nvim')
        call dein#add('roxma/nvim-yarp')
        call dein#add('roxma/vim-hug-neovim-rpc')
  endif
  call dein#add('tomasr/molokai')


  call dein#end()
  call dein#save_state()
endif

if dein#check_install()
  call dein#install()
endif

俺たちのVimはこれからだ!ご愛読ありがとうございました。
次回のVimの記事にご期待ください。

参考

http://vim-jp.org/docs/build_linux.html
http://www.jonki.net/entry/2014/05/04/183250

3
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
6