vim 重新编译,支持lua (compile vim with lua)
1. ncurses 安装
官网下载:http://ftp.gnu.org/pub/gnu/ncurses/ncurses-5.9.tar.gz
CSDN 下载:http://download.csdn.net/detail/spch2008/8828779
tar -xf ncurses-5.9.tar.gz cd ncurses-5.9 ./configure make sudo make install
ubuntu编译错误解决:① export CPPFLAGS="-P" ② 重新configure,再make
2. lua 安装
官方网下载:http://www.lua.org/download.html
CSDN 下载:http://download.csdn.net/detail/spch2008/8828787
tar -xf lua-5.3.1.tar.gz cd lua-5.3.1 make linux sudo make install
问题一:
error: readline/readline.h: No such file or directory
下载readline
CSDN下载:http://download.csdn.net/detail/spch2008/8828777
cd readline-5.2 ./configure sudo make sudo make install
问题二:
//usr/local/lib/libreadline.so: undefined reference to `tputs' //usr/local/lib/libreadline.so: undefined reference to `tgoto' //usr/local/lib/libreadline.so: undefined reference to `tgetflag' //usr/local/lib/libreadline.so: undefined reference to `UP' //usr/local/lib/libreadline.so: undefined reference to `tgetent' //usr/local/lib/libreadline.so: undefined reference to `tgetnum' //usr/local/lib/libreadline.so: undefined reference to `PC' //usr/local/lib/libreadline.so: undefined reference to `tgetstr' //usr/local/lib/libreadline.so: undefined reference to `BC' collect2: error: ld returned 1 exit status
添加 -lncurses 参数
/home/spch2008/lua-5.3.1/src/Makefile
linux: 110 $(MAKE) $(ALL) SYSCFLAGS="-DLUA_USE_LINUX" SYSLIBS="-Wl,-E -ldl -lreadline -lncurses"
3. vim 安装
官方下载:ftp://ftp.vim.org/pub/vim/unix/vim-7.4.tar.bz2
CSDN下载:http://download.csdn.net/detail/spch2008/8828773
tar -xf vim-7.4.tar.bz2 cd vim74 ./configure --prefix=/usr --with-features=huge --enable-rubyinterp --enable-pythoninterp --enable-luainterp --with-lua-prefix=/usr/local
sudo make
sudo make install
可以将输出重定向到log文件中,查看configure输出:
cat log | grep lua
spch2008@ubuntu:~/vim74$ cat log | grep lua checking --enable-luainterp argument... yes checking --with-lua-prefix argument... /usr/local checking --with-luajit... no checking for lua... /usr/local/bin/lua checking if lua.h can be found in /usr/local/include... yes checking if link with -L/usr/local/lib -llua is sane... yes
问题:
objects/if_lua.o: In function `luaV_list_insert': /home/spch2008/vim74/src/if_lua.c:777: undefined reference to `luaL_optlong' collect2: error: ld returned 1 exit status
修改文件 /home/spch2008/vim74/src/if_lua.c
//long pos = luaL_optlong(L, 3, 0);
long pos = (long)luaL_optinteger(L, 3, 0);
4. 安装成功,检测时间,可能遇到问题
打开vim,输入:version, 查看vim编译时间,如果是本次编译生成,则说明正确,然后查看是否有+lua。
若编译时间不正确,则删除旧vim,拷贝新的vim程序
sudo rm -f /usr/bin/vim sudo rm -f /usr/local/bin sudo cp ~/vim74/src/vim /usr/bin sudo cp ~/vim74/src/vim /usr/local/bin
附:
更改$VIM变量。编译完成后,我的$VIM变量是/usr/share/vim,一般默认都是在/etc,因而进行修改。
上图,输入version查看,vim 读取全局配置文件vimrc的路径为$VIM,通过:echo $VIM,
可知,目前我的VIM路径为/usr/share/vim。
在os_unix.h文件中,改为:# define SYS_VIMRC_FILE "/etc/vimrc"。重新进行make, make install 即可。
查看vim加载的脚本,输入:scriptnames 。可以看到vim已经加载的文本。