Home  >  Article  >  Development Tools  >  Share Sublime installation YcmdCompletion record

Share Sublime installation YcmdCompletion record

藏色散人
藏色散人forward
2021-06-19 17:32:132549browse

The following is the tutorial column of sublime to introduce the Sublime installation YcmdCompletion record. I hope it will be helpful to friends in need!

Sublime installation YcmdCompletion record

YcmdCompletion is a semantic completion plug-in based on Clang. The installation is divided into client and server.

1. Install the client

  1. Search for Package Control and select YcmdCompletion

2 . Install the server

There are two ways to start the server, manual and automatic.

2.1 Manual method:

Compile the ycmd service. This needs to be compiled by yourself on the corresponding platform. It will download clang and other libraries. Compilation method original text

Install compilation tools

sudo apt-get install build-essential cmake python-dev

Download the ycmd source code. I downloaded the code directly to the User directory of sublime. After the build, the clang library will be automatically downloaded.

cd ~/.config/sublime-text-3/User
git clone git@github.com:Valloric/ycmd.git && cd ycmd
git submodule update --init --recursive
./build.py --all

In about half an hour, the installation was successful. The author updates frequently. Now only one library, ycm_core.so, will be generated after compilation. There was also a ycm_client_support.so before, which is now Merged.
Share Sublime installation YcmdCompletion record

Next, start the server manually (note that the current directory is always under the ycmd directory). Server startup requires a configuration file ycmd/default_settings.json, each It will be automatically deleted after the first startup, so we first copy a copy to the current directory

cp ycmd/default_settings.json .

and then open it to modify two items, global_ycm_extra_confSpecify the location of the default .ycm_extra_conf.py andhmac_secretSet the HMAC key.
Default.ycm_extra_conf.pyDownload, used to configure the completion function settings, specific parameters can be found in the document.ycm_extra_conf.py configuration

wget https://raw.githubusercontent.com/Valloric/ycmd/master/cpp/ycm/.ycm_extra_conf.py

Generate HMAC key

Command Palette > Ycmd: Create HMAC keys

The server is written in python, so there is a __main__.py file under ycmd/ycmd, and we can start it.

python ycmd --port 8888 --options_file ycmd/default_settings.json

Share Sublime installation YcmdCompletion record

The server has been started. Next, configure the sublime-text client and open the Ycmd configuration filePreferences > Package Settings > YcmdCompletion > Settings - Default, modify ycmd_port port.

The biggest advantage of this method is that the server can be deployed remotely or made into a Docker image. You only need to specify the ip and port and you can use it at will.

2.2 Automatic method

Open the Ycmd configuration file Preferences > Package Settings > YcmdCompletion > Settings - Default, just set 3 parameters.

  /* =====       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",

3. Start Sublime and test

Set the completion triggering rules, open Preferences -> Settings - More -> Syntax Specific - User, insert Code below. In this way, when entering , ::, ->, automatic completion can be triggered. I added /, which can trigger path completion. Otherwise, you need to enter matching characters to complete.

{
    "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": "/"} 
    ]
}

ycmd command list, including restarting the server, displaying error list, etc.

Command Palette > Ycmd:

The above is the detailed content of Share Sublime installation YcmdCompletion record. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:segmentfault.com. If there is any infringement, please contact admin@php.cn delete