1. 安裝客戶端
搜尋Package Control,選擇YcmdCompletion 可以
sudo apt-get install build-essential cmake python-dev
cd ~/.config/sublime-text-3/User git clone git@github.com:Valloric/ycmd.git && cd ycmd git submodule update --init --recursive ./build.py --all
ycm_client_support.so,現在被合併了。
ycmd/default_settings.json, 每次啟動之後會自動被刪除掉,所以我們先拷貝一份到當前目錄下
cp ycmd/default_settings.json .
global_ycm_extra_conf指定預設的.ycm_extra_conf.py的位置和
hmac_secret設定HMAC的key。
預設的
.ycm_extra_conf.py下載,用來配置補全功能的設置,具體參數可以看文檔.ycm_extra_conf.py配置
wget https://raw.githubusercontent.com/Valloric/ycmd/master/cpp/ycm/.ycm_extra_conf.py
Command Palette > Ycmd: Create HMAC keys
python ycmd --port 8888 --options_file ycmd/default_settings.json
Preferences > Package Settings > YcmdCompletion > Settings - Default, 修改
ycmd_port埠。
Docker image,只需要指定ip和port就可以任意使用了。
Preferences > Package Settings > YcmdCompletion > Settings - Default,設定3個參數即可。
/* ===== YCMD AUTO START MODE =====*/ "use_auto_start_localserver": 1, "ycmd_path": "/home/will/.config/sublime-text-3/Packages/User/ycmd/ycmd", "python_binary_path": "/usr/bin/python",
Preferences -> Settings - More -> Syntax Specific - User,插入下面程式碼。這樣當輸入
, ::, ->就可以觸發自動補全了。我增加了
/,可以觸發路徑補全,否則需要輸入相符的字元才能補全。
{ "auto_complete_selector": "source - (comment, string.quoted)", "auto_complete_triggers": [ {"selector": "source.c++", "characters": "."}, {"selector": "source.c++", "characters": "::"}, {"selector": "source.c++", "characters": "->"}, {"selector": "source.c++", "characters": "/"} ] }
Command Palette > Ycmd: