Skip to content
This repository has been archived by the owner on Jul 30, 2020. It is now read-only.

Initialization options

Fangrui Song edited this page Jan 23, 2018 · 26 revisions

You need to configure your language client plugin to send initialization options to the cquery process (the language server). cacheDirectory points to a directory storing indexing files so that next time cquery can load these indexing results without doing a re-index.

{
  "initializationOptions": {
    "cacheDirectory": "/tmp/cquery",
    "cacheFormat": "msgpack",
    "completion": {
      "filterAndSort": true
    },
    "indexerCount": 0,
    "index": {
      "builtinTypes": false,
      "comments": 2,
    },
  }
}

You can also pass options through the cquery command line option --init:

  • shell: --init='{"enableComments": 2}' . Single quotes are used to escape words in shell.
  • VSCode: "cquery.launch.args": ["--init={\"enableComments\": 2}"],
  • Emacs: (setq cquery-extra-init-params '(:enableComments 2 :cacheFormat "msgpack"))

indexerCount number of indexer threads

If indexerCount is 0, use 80% of std::thread::hardware_concurrency().

index.builtinTypes

  • false, default
  • true, index builtin types such as: char,int,bool,long

textDocument/defintion on variables does not bring to builtin types because they have no declaration range. However, you may use $cquery/vars on variables to browse their instances.

index.comments: indexing comments

  • 0, don't index comments
  • 1, index Doxygen comment markers
  • 2, use -fparse-all-comments and recognize plain // /* */ besides Doxygen comment markers

With the value larger than 0, cquery will index comments associated with functions/types/variables (macros are not handled due to clang_Cursor_getRawCommentText's peculiarity).

This feature requires UI support as multi-line hover results poses a problem to editors:

cacheFormat: serialization format of cache files

Two cache serialization formats are supported.

"cacheFormat": "json"
"cacheFormat": "msgpack"

"json" generates cacheDirectory/.../xxx.json files which can be pretty printed with jq.

"msgpack" uses a compact binary serialization format (the underlying wire format is MessagePack) which typically takes only 60% of the corresponding JSON size, but is difficult to inspect. "msgpack" does not store map keys and you need to re-index whenever a struct member has changed.

completion.filterAndSort: completion filtering and sorting

Cquery filters and sorts completions to try to be nicer to clients that can't handle big numbers of completion candidates. This behaviour can be disabled by specifying false for the option.

This option is the most useful for LSP clients that implement their own filtering and sorting logic.

"resourceDirectory": Clang resource directory

bin/cquery tries to find the suitable clang resource directory for you. If the heuristic does not work, you can specify it: "resourceDirectory": "/path/to/lib/clang/5.0.1/"