Skip to content

Instantly share code, notes, and snippets.

@hydrargyrum
Last active November 17, 2015 14:09
Show Gist options
  • Save hydrargyrum/78c6fccc9de622ad9d7b to your computer and use it in GitHub Desktop.
Save hydrargyrum/78c6fccc9de622ad9d7b to your computer and use it in GitHub Desktop.
ycmd protocol documentation draft

Running YCMD

Command-line options

--host ADDRESS
    ... If not specified, 127.0.0.1 is used.

--port PORT
    Listen on PORT. If not specified, will use any available port.

--log [debug|info|warning|error|critical]
    Set level of logging of the server. The default is 'info'

--idle_suicide_seconds N
    Quit server if no requests are made for N seconds. 0 disables automatic
    quitting (the default).

--options_file FILE
    Use options from JSON FILE. Mandatory.

--stdout FILE
    If specified, redirect stdout to FILE.

--stderr FILE
    If specified, redirect stderr to FILE.

--keep_logfiles
    Retain logfiles after the server exits.

Options file

The options file is a JSON dictionary in a file passed on the command line. The keys of the dictionary are:

hmac_secret
    BASE64($secret), where $secret is 16 random bytes. Mandatory. The
    secret value will be used for all server communications.

auto_trigger
    boolean.

filepath_completion_use_working_dir
    boolean.

min_num_of_chars_for_completion
    number.

min_num_identifier_candidate_chars
    number.

semantic_triggers
    number.

filetype_specific_completion_to_disable
    dictionary. filetypes strings as keys, any value is accepted.

seed_identifiers_with_syntax
    boolean.

collect_identifiers_from_comments_and_strings
    boolean.

collect_identifiers_from_tags_files
    boolean.

max_num_identifier_candidates
    number.

extra_conf_globlist
    list.

global_ycm_extra_conf
    string.

confirm_extra_conf
    boolean.

complete_in_comments
    boolean.

complete_in_strings
    boolean.

max_diagnostics_to_display
    number.

filetype_whitelist
    dictionary. filetypes strings as keys, any value is accepted.

filetype_blacklist
    dictionary. filetypes strings as keys, any value is accepted.

auto_start_csharp_server
    boolean.

auto_stop_csharp_server
    boolean.

use_ultisnips_completer
    boolean.

csharp_server_port
    boolean.

server_keep_logfiles
    boolean.

gocode_binary_path
    string.

The YCM protocol

YCMD is an HTTP server to which requests can be made.

Request Headers

Every request to the YCMD server MUST include a 'X-Ycm-Hmac' header. Its value is computed as follows:

BASE64(HMAC($secret, JOIN(HMAC($secret, $request_method),
                          HMAC($secret, $request_path),
                          HMAC($secret, $request_body))))

HMAC uses SHA-256 as digest method. $secret is the 16 bytes random string previously chosen.

If the request is empty, body is considered empty in the computation.

POST requests

For every POST request, the 'Content-Type' header must have 'application/json' as value. The parameters of the request are passed in the body, as a JSON dictionary. The dictionary must be UTF-8 encoded.

Common parameters

In parameters of a request, some keys are often present. They will be described here.

filepath
    String. The absolute path of the file the request should operate on.

file_data
    Dictionary. Each key is a relative filename, and the values are
    dictionaries with the following sub-keys:
        filetypes
            List of strings. Lists the filetypes of the specified file.

        contents
            String. Whole data content of the specified file.

line_num
    Number. The line where to do the operation, starting at line 1.

column_num
    Number. The column where to do the operation, starting at column 1.

Response headers

Every response from the YCMD server MUST include a 'X-Ycm-Hmac' header. Its value is computed as follows:

BASE64(HMAC($secret, $response_body))

Endpoints

The endpoints are:

GET /healthy

GET /ready?include_subservers=<boolean>
    Parameters:
        include_subservers
            TODO

POST /defined_subcommands
    Keys:
        completer_target
            String. Can be 'python'.

POST /completions
    Get the possible completions strings.

    Keys:

POST /run_completer_command
    Keys:
        command_arguments
            List of strings.

            Accepted values are:
                GoTo
                    TODO

        filepath
        file_data
        line_num
        column_num
            See `common parameters`.


POST /event_notification
    Keys:
        event_name
            Can be one of:
                FileReadyToParse
                    The server should parse the specified file.

                BufferUnload
                    TODO

                BufferVisit
                    TODO

                InsertLeave
                    TODO

                CurrentIdentifierFinished
                    TODO

        filepath
        file_data
        line_num
        column_num
            See `common parameters`.

POST /load_extra_conf_file
    Keys:
        filepath
            string. Path of the extra conf to read.


POST /ignore_extra_conf_file

POST /debug_info
POST /semantic_completion_available
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment