Linux安裝YouCompleteMe一般有兩種方法,使用bundle安裝,或者直接使用git clone https://github.com/ycm-core/YouCompleteMe.git ~/.vim/bundle
,可是無論哪種方法,(國內)經常會卡在安裝第三方包時/go/src/golang.org/x/tools
這兒。
原因: 無論哪種方法,執行完git clone https://github.com/ycm-core/YouCompleteMe.git ~/.vim/bundle
後,需要在~/.vim/bundle/YouCompleteMe
路徑下進行操作git submodule update --init --recursive
,由於有一個源是google的,國內連不上,所以會出錯。
修改辦法:
首先將之前失敗的安裝都刪除,然後按照下面方法一步步安裝,或者直接按照步驟3修改後重新安裝。
-
跟之前一樣先執行
git clone https://github.com/ycm-core/YouCompleteMe.git ~/.vim/bundle
,此時路徑~/.vim/bundle/YouCompleteMe/third_party/ycmd
爲空的。 -
然後在文件夾
YouCompleteMe
中執行git submodule update --init
。此時沒有--recursive
此時路徑~/.vim/bundle/YouCompleteMe/third_party/ycmd
下會增加很多文件, -
然後編輯文件
vim ~/.vim/bundle/YouCompleteMe/third_party/ycmd/.gitmodules
。
將最後[submodule "third_party/go/src/golang.org/x/tools"]
中的URL如下修改:
將
url = https://go.googlesource.com/tools
ignore = dirty
修改爲
url = https://github.com/golang/tools
-
再按要求執行
git submodule update --init --recursive
-
之後的安裝跟配置網上都有很多