背景:
MacBook 13' 2015 Early;macOS10.15.3;vim-plug;alias python = python3
實操過程:
Mac需要有cmake才能正常運行YCM
brew install cmake
然后使用vim-plug安裝youcompleteme
vim ~/.vimrc
press "i" enter insert model
加入如下代碼在vimrc中
call plug#begin('~/.vim/plugged')
Plug 'Valloric/YouCompleteMe'????????" 要安裝的插件寫在兩個call之間
call plug#end()
esc + :x 保存并退出
然后進入VIM,
:PlugInstall
命令安裝插件
(如遇到網絡相關問題報錯,終端默認無法走proxy,需要手動設置一下)
完成后,依照教程方法編譯
cd ~/.vim/plugged/youcompleteme
./install.py --all
問題:再次進入VIM提示??????
YouCompleteMe unavailable: requires Vim compiled with Python (3.5.1+) support.
查了一些方法,包括重新brew install vim 了一下,依舊沒有正常。
猜測可能是因為沒有用python3編譯的原因
故如下
cd ~/.vim/plugged/youcompleteme
sudo python3 ./install.py --clang-completer ###使用此命令可只用C語言的補全,速度會更快###
#sudo python3 ./install.py --all ? ?###此命令為所有補全的安裝
cp ~/.vim/plugged/YouCompleteMe/third_party/ycmd/examples/.ycm_extra_conf.py ~/ ? ? ?###復制默認配置文件到根目錄
強制指定python3編譯,--all的話過程中會涉及到下載Omnisharp、rust等等,會有些漫長,取決于網絡狀況。
使用all參數的話,
To simply compile with everything enabled, there's a?--all?flag. So, to install with all language features, ensure?xbuild,?go,?tsserver,?node,?npm,?rustc, and?cargo?tools are installed and in your?PATH
一般可按需加入自己用的參數就好
The following additional language support options are available:
C# support: install Mono with?Homebrew?or by downloading the?Mono Mac package?and add?--omnisharp-completer?when calling?./install.py.
Go support: install?Go?and add?--gocode-completer?when calling?./install.py.
TypeScript support: install?Node.js and npm?then install the TypeScript SDK with?npm install -g typescript.
JavaScript support: install?Node.js and npm?and add?--tern-completer?when calling?./install.py.
Rust support: install?Rust?and add?--racer-completer?when calling?./install.py.
進入VIM,:PlugStatus 查看插件狀態(tài)

最后再對YouComleteMe進行簡單配置
vi ~/.vimrc
let g:ycm_global_ycm_extra_conf='~/.ycm_extra_conf.py' "設置全局配置文件的> 路徑
let g:ycm_seed_identifiers_with_syntax=1? ? " 語法關鍵字補全
let g:ycm_confirm_extra_conf=0? " 打開vim時不再詢問是否加載ycm_extra_conf.py? ? 配置
let g:ycm_key_invoke_completion = '<C-a>' " ctrl + a 觸發(fā)補全
set completeopt=longest,menu? ? "讓Vim的補全菜單行為與一般IDE一致(參考VimTip? ? 1228)
提示
ERROR: Unable to find executable 'go'. go is required to build gopls.
是因為環(huán)境沒有安裝golang,有需求可以brew install golang一下
提示
ERROR: Unable to find executable 'npm'. npm is required to set up Tern.
則是缺少node ,brew intall node ? ? ?一下