前言
第一次尝试编译,小心翼翼。对满血版的vim有需求,决心一试。
参考链接,感谢各位,尤其是yangyangwithgnu,让我在折腾vim的路上越走越远。
https://github.com/yangyangwithgnu/use_vim_as_ide#1
https://blog.csdn.net/Asdfffy/article/details/81417432
https://www.jianshu.com/p/3e0c242310d3
https://github.com/Valloric/YouCompleteMe/wiki/Building-Vim-from-source
更新,编译vim82,记录一下新的编译选项,python路径的选项废弃了
./configure --with-features=huge \
--enable-multibyte \
--enable-rubyinterp=yes \
--enable-python3interp=yes \
--enable-perlinterp=yes \
--enable-luainterp=yes \
--enable-cscope \
--prefix=/usr/local
新的问题:
E185: Cannot find color scheme 'molokai'
需要把插件中~/.vim/bundle/molokai/colors
复制到~/.vim
~/.vimrc
的配置对sudo
无效
以root
登录,在/root/
下对vim重新配置
过程
各方考证,小心谨慎,一切顺利。就是Anaconda啊!!!!
卸载原来的弱鸡版的vim
dpkg -l | grep vim
sudo apt-get remove vim vim-runtime vim-tiny vim-common
下载源码到某处
git clone git@github.com:vim/vim.git
cd vim/
查看设置说明,明白相关参数设置,更能理解参考链接的教程
./configure -h
安装的环境准备,Ubuntu和openSUSE还是有差的,环境没弄好编译据说不会报错但是功能会缺失。这基本是我多方参照最齐全的了,亲测的可用,要玩就玩大的。
sudo apt install build-essential libncurses5-dev python-dev python3-dev \
ruby-dev liblua5.2-dev lua5.2 libperl-dev libx11-dev libxt-dev \
libxpm-dev libgnomeui-dev libgnome2-dev libgtk2.0-dev libatk1.0-dev \
libbonoboui2-dev libcairo2-dev
编译安装,超级多的选项,综合了四个教程和源码说明。有几个矛盾的地方,./configure -h
中说 –with-python-config-dir=PATH Python’s config directory (deprecated) ,但是还是给路径吧,才吃够 Anaconda 同名的亏,同时路径也要注意是否正确,最好自己确认一下。wiki
说 Note for Ubuntu users: You can only use Python 2 or Python 3,但是给的例子又都有。不是太理解,还是全安了。
以及yangyangwithgnu大佬的教程确实老了点,像参数后面的yes,目测还是要的。就我的经验,权限够的话能不sudo
就不了,但不知道行不行。UI的话,选了gtk2
,不是太懂。
./configure \
--with-features=huge \
--enable-multibyte \
--enable-rubyinterp=yes \
--enable-pythoninterp=yes \
--with-python-config-dir=/usr/lib/python2.7/config-x86_64-linux-gnu \
--enable-python3interp=yes \
--with-python-config-dir=/home/dragon/anaconda3/lib/python3.7/config-3.7m-x86_64-linux-gnu \
--enable-perlinterp=yes \
--enable-luainterp=yes \
--enable-gui=gtk2 \
--enable-cscope \
--prefix=/usr/local/
make && src/vim --version
多方论证选了上述参数,来吧!要是编译效果不好,就重来。
make clean
要是感觉不够彻底还可以
rm /src/auto/config.cache
cd src/ && make clean
重复编译了非常多次,都是python3的问题,试了很多种方法,果然还是 Anaconda啊,气死。最后--with-python-config-dir
用/home/dragon/anaconda3/lib/python3.7/config-3.7m-x86_64-linux-gnu \
而非/usr/lib/python3.6/config-3.6m-x86_64-linux-gnu/
才得以解决,气死。附上最终版本信息,应该是ok了。
VIM - Vi IMproved 8.1 (2018 May 18, compiled Jun 20 2019 01:33:11)
Included patches: 1-1568
Compiled by dragon@LoveBin
Huge version with GTK2 GUI. Features included (+) or not (-):
+acl -farsi -mouse_sysmouse -tag_any_white
+arabic +file_in_path +mouse_urxvt -tcl
+autocmd +find_in_path +mouse_xterm +termguicolors
+autochdir +float +multi_byte +terminal
-autoservername +folding +multi_lang +terminfo
+balloon_eval -footer -mzscheme +termresponse
+balloon_eval_term +fork() +netbeans_intg +textobjects
+browse +gettext +num64 +textprop
++builtin_terms -hangul_input +packages +timers
+byte_offset +iconv +path_extra +title
+channel +insert_expand +perl +toolbar
+cindent +job +persistent_undo +user_commands
+clientserver +jumplist +postscript +vartabs
+clipboard +keymap +printer +vertsplit
+cmdline_compl +lambda +profile +virtualedit
+cmdline_hist +langmap +python/dyn +visual
+cmdline_info +libcall +python3/dyn +visualextra
+comments +linebreak +quickfix +viminfo
+conceal +lispindent +reltime +vreplace
+cryptv +listcmds +rightleft +wildignore
+cscope +localmap +ruby +wildmenu
+cursorbind +lua +scrollbind +windows
+cursorshape +menu +signs +writebackup
+dialog_con_gui +mksession +smartindent +X11
+diff +modify_fname +sound -xfontset
+digraphs +mouse +spell +xim
+dnd +mouseshape +startuptime +xpm
-ebcdic +mouse_dec +statusline +xsmp_interact
+emacs_tags -mouse_gpm -sun_workshop +xterm_clipboard
+eval -mouse_jsbterm +syntax -xterm_save
+ex_extra +mouse_netterm +tag_binary
+extra_search +mouse_sgr -tag_old_static
system vimrc file: "$VIM/vimrc"
user vimrc file: "$HOME/.vimrc"
2nd user vimrc file: "~/.vim/vimrc"
user exrc file: "$HOME/.exrc"
system gvimrc file: "$VIM/gvimrc"
user gvimrc file: "$HOME/.gvimrc"
2nd user gvimrc file: "~/.vim/gvimrc"
defaults file: "$VIMRUNTIME/defaults.vim"
system menu file: "$VIMRUNTIME/menu.vim"
fall-back for $VIM: "/usr/local/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK -pthread -I/usr/include/gtk-2.0 -I/usr/lib/x86_64-linux-gnu/gtk-2.0/include -I/usr/include/gio-unix-2.0/ -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng16 -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/freetype2 -I/usr/include/libpng16 -g -O2 -D_REENTRANT -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: gcc -L. -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -fstack-protector -rdynamic -Wl,-export-dynamic -Wl,-E -L/usr/local/lib -Wl,--as-needed -o vim -lgtk-x11-2.0 -lgdk-x11-2.0 -lpangocairo-1.0 -latk-1.0 -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lpangoft2-1.0 -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lfontconfig -lfreetype -lSM -lICE -lXpm -lXt -lX11 -lXdmcp -lSM -lICE -lm -ltinfo -lnsl -lselinux -lcanberra -ldl -L/usr/lib -llua5.2 -Wl,-E -fstack-protector-strong -L/usr/local/lib -L/usr/lib/x86_64-linux-gnu/perl/5.26/CORE -lperl -ldl -lm -lpthread -lcrypt -lruby-2.5 -lpthread -lgmp -ldl -lcrypt -lm
确认无误后
sudo make install
具体参数也无力解释了,参考的地方都列了。
注:安装后vim的路径不同与原来的/usr/share/vim/vim80
,依上面配置转移到了/usr/local/share/vim/vim81
。
感想
之所以这么折腾,一方面是崇尚大道至简,一方面在尝试use_vim_as_ide的时候很多东西想试试,用不了很不爽,当然了,也很喜欢vim。果然 Anaconda 总是会坑我,体验新生的vim了!
最后引yangyangwithgnu大佬的译文吧
vi 之大道如我心之禅,
vi 之漫路即为禅修,
vi 之命令禅印于心,
未得此道者视之怪诞,
与之为伴者洞其真谛,
长修此道者巨变人生。
更新
- vim的括号自动补全,加在
.vimrc
上" 自动补全 inoremap ( ()<ESC>i inoremap { {}<ESC>i inoremap [ []<ESC>i inoremap " ""<ESC>i inoremap ' ''<ESC>i