编译 vim7.3 ( Winows and Linux)
2011年8月01日 17:40
最近将windows和ubuntu以及Archlinux下的vim都重新在本地编译并安装为最新版本, 因为vim.org提供的版本往往版本滞后而且没有编译需要的特性,必须自行编译。 将安装过程记录下来,以资参考。
Windows
- 原版问题:
1. 缺少python3 等所需特性。
2. 没有字体渲染
3. 没有等宽字体支持
- 配置环境:
1. 安装 MSYS-cn ,这个比MinGW更为方便
2. 下载并安装Lua/Python/Perl/Ruby等所需程序
- 下载源码:
hg clone https://vim.googlecode.com/hg/ vim 如果已下载,只需 hg pull
- 添加字体渲染,修改src/gui_w32.c
diff -r 6768ebd0bc04 -r 213b33df021a src/gui_w32.c --- a/src/gui_w32.c Sun Aug 08 16:38:42 2010 +0200 +++ b/src/gui_w32.c Sat Sep 18 10:37:41 2010 +0800 @@ -2298,7 +2298,11 @@ /* On NT, tell the font renderer not to "help" us with Hebrew and Arabic * text. This doesn't work in 9x, so we have to deal with it manually on * those systems. */ - if (os_version.dwPlatformId == VER_PLATFORM_WIN32_NT) + if ( +#ifdef FEAT_RIGHTLEFT + curwin->w_p_rl && +#endif + os_version.dwPlatformId == VER_PLATFORM_WIN32_NT) foptions |= ETO_IGNORELANGUAGE;
- 添加非等宽字体支持,修改src/os_mswin.c
diff -r 96b2b1cca7cd src/os_mswin.c --- a/src/os_mswin.c Mon Aug 23 12:55:47 2010 +0800 +++ b/src/os_mswin.c Mon Aug 23 13:05:17 2010 +0800 @@ -3288,8 +3288,11 @@ #ifndef FEAT_PROPORTIONAL_FONTS /* Ignore non-monospace fonts without further ado */ + /* + * hzmangel: I need non-monospace fonts! if ((ntm->tmPitchAndFamily & 1) != 0) return 1; + */ #endif /* Remember this LOGFONT as a "possible" */
- 编译
注意:需要修改python/ruby等路径为本机安装位置 在MSYS-cn 下, c: , d: 盘符为 /c , /d
cd vim/src make -f Make_ming.mak \ PYTHON=/d/python27 PYTHON_VER=27 \ PYTHON3=/d/python31 PYTHON3_VER=31 \ RUBY=/d/Ruby192 RUBY_VER=19 RUBY_VER_LONG=1.9.1 \ gvim.exe make -f Make_ming.mak \ PYTHON=/d/python27 PYTHON_VER=27 \ PYTHON3=/d/python31 PYTHON3_VER=31 \ RUBY=/d/Ruby192 RUBY_VER=19 RUBY_VER_LONG=1.9.1 \ GUI=no vim.exe
- 安装
最后将编译生成的exe文件拷贝到'$VIM/vimfile'文件夹就可以了。
vim的script文件都在源码包的runtime文件夹里, 可以将其复制到'$VIM/vimfile'文件夹
- 使用
win下我是使用文泉驿微米黑
set gfw=Wenquanyi_Micro_Hei_Mono:h13:cANSI
Ubuntu
# install dependency sudo apt-get install grep curl ctags cscope sudo apt-get install libncurses5-dev libgnome2-dev libgnomeui-dev \ libgtk2.0-dev libatk1.0-dev libbonoboui2-dev \ libcairo2-dev libx11-dev libxpm-dev libxt-dev sudo apt-get install python python-dev python3 python3-dev python2.7 python2.7-dev sudo apt-get install ruby ruby-dev # download src code or use 'hg pull' to update only hg clone https://vim.googlecode.com/hg/ vim cd vim/src # use ./configure --help to see features ./configure --enable-multibyte --with-features=huge --enable-gui=gnome2 \ --enable-python3interp=yes --enable-rubyinterp --enable-pythoninterp=yes \ --enable-tclinterp --enable-fontset \ sudo make && sudo make install
Arch Linux
- 官方源问题:
1. 其python的默认链接为python3
2. 好几个版本官方源里vim编译时的python2链接的gtk库存在问题,
- 安装过程
# install +ruby +lua feature dependency. sudo pacman -S ruby lua # download src code or use 'hg pull' to update only hg clone https://vim.googlecode.com/hg/ vim cd vim/src # fix python name sed -i -e 's|vi_cv_path_python, python)|vi_cv_path_python, python2)|' \ configure.in # use ./configure --help to see features ./configure --prefix=/usr \ --enable-multibyte --with-features=huge --enable-gui=gtk2 \ --enable-python3interp=yes --enable-rubyinterp \ --enable-pythoninterp=yes --enable-luainterp\ --enable-tclinterp --enable-fontset --enable-netbeans \ sudo make && sudo make install
Update:2012-04-17 整理注释。
Update:2012-03-16 整理并增加Archlinux部分。
Update:2012-04-01 整理Windows部分。