Vim
{% include JB/setup %}
Compile
macOS
Python Support
brew install python
brew install python3
Vim will drop all python linking flags while you build with enable both python2 and python3 binding.
So use either --enable-pythoninterp or --enable-python3interp. Do not use both of them.
If use both, /opt/bin/vim --version shows +python/dyn and +python3/dyn
But :py3 print("hello") in vim returns
E370: Could not load library
E263: Sorry, this command is disabled, they Python library could not be loaded.
Python library could not be loaded
Lua Support
brew install lua --with-completion
Method 1: MacVim (Recommended)
Method 1.1: Homebrew (Recommended)
brew info macvim
brew options macvim
brew install macvim --with-luajit --override-system-vim
Add these lines to ~/.zshrc
alias vi="mvim -v"
alias vim="mvim -v"
Method 1.2: Build From Source
Can NOT use YouCompleteMe
https://github.com/macvim-dev/macvim/releases
mkdir -p ~/src/vim/
cd ~/src/vim/
tar xf macvim-snapshot-74.tar.gz
cd macvim-snapshot-74/src
./configure --with-features=huge --with-compiledby=taohe --enable-multibyte --enable-xim --enable-cscope --enable-rubyinterp --enable-pythoninterp --enable-perlinterp --enable-luainterp --with-lua-prefix=/usr/local/Cellar/lua/5.2.3_1
make
Add these lines to ~/.zshrc
alias vi='vim'
alias vim="$HOME/src/vim/macvim-snapshot-74/src/MacVim/build/Release/MacVim.app/Contents/MacOS/Vim"
Method 2: Vim
Download Vim Source
brew install ncurses
mkdir -p ~/src/vim/
cd ~/src/vim/
tar jxf vim-7.4.tar.bz2
Patch Vim
cd ~/src/vim/
tar zxf vimgdb-for-vim7.4.tar.gz
patch -p0 < vimgdb-for-vim7.4/vim74.patch
Fix Bugs on macOS
This patch must be applied after vimgdb patch
patch -p0 < vimgdb74osxfix/vimgdb74osxfix.patch
Configure and Make
cd vim74/src/
with python2
./configure --with-features=huge --with-compiledby=taohe --enable-multibyte --enable-xim --enable-cscope --enable-rubyinterp --enable-pythoninterp --enable-perlinterp --enable-luainterp --enable-gdb --with-lua-prefix=/usr/local/Cellar/lua/5.2.3_1
with python3
./configure --with-features=huge --with-compiledby=taohe --enable-multibyte --enable-xim --enable-cscope --enable-rubyinterp --enable-python3interp --enable-perlinterp --enable-luainterp --enable-gdb --with-lua-prefix=/usr/local/Cellar/lua/5.2.3_1
make
sudo make install
/opt/bin/vim --version
Ensure +gdb and +python3
Link
Add /opt/bin to $PATH in ~/.zshrc
link vi
cd /usr/local/bin
if test -f vi; then
mv -f vi vi.bak
fi
ln -s /opt/bin/vim vi
cd -
Ubuntu
vi/vim使用进阶: 在VIM中使用GDB调试 – 使用vimgdb
ubuntu8.10及之后版本build编译vim出现buffer overflow【修正上面的方法中运行会崩溃】
即make之前先运行下面命令
./configure --enable-cscope --enable-gdb --enable-multibyte --enable-xim --enable-pythoninterp CFLAGS="-O3 -D_FORTIFY_SOURCE=1"
Advanced
vi/vim使用进阶: 在VIM中使用GDB调试 – 使用pyclewn
使用gvim+pyclewn+gdbserver进行远程调试
Configuration
Plugins
Profile
vim --cmd "profile start profile.txt" --cmd "profile file ~/.config/nvim/vimrc" +q && vim profile.txt