-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
https://github.com/cquery-project/cquery is a low-latency language server supporting multi-million line C++ code-bases, powered by libclang. Please refer to https://github.com/cquery-project/cquery/wiki/Emacs
- Loading branch information
Showing
5 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#+TITLE: cquery layer | ||
|
||
* Table of Contents :TOC_4_gh:noexport: | ||
- [[#description][Description]] | ||
- [[#features][Features:]] | ||
- [[#install][Install]] | ||
- [[#cquery-server][cquery server]] | ||
- [[#layer][Layer]] | ||
- [[#configuration][Configuration]] | ||
|
||
* Description | ||
This layer adds [[https://github.com/cquery-project/cquery][cquery]] support. | ||
|
||
** Features: | ||
- Cross references (definitions, references, base/derived classes/methods, type instances, ...) | ||
- Workspace symbol search | ||
- Workspace-wide symbol rename | ||
- Diagnostics | ||
- Completion with =company-lsp= | ||
- Rainbow semantic highlighting | ||
- Signature help and documentation | ||
- Code lens | ||
- See more on [[https://github.com/cquery-project/cquery/wiki/Emacs]] | ||
|
||
Some features are implemented on the server side but not available in the Emacs plugin, e.g. type hierarchy, member hierarchy, call tree. | ||
|
||
* Install | ||
** cquery server | ||
Install the =cquery= server. [[https://github.com/cquery-project/cquery/wiki/Getting-started][Instructions]]. | ||
|
||
** Layer | ||
1) Add =cquery= to the =dotspacemacs-configuration-layers= list in =~/.spacemacs=. | ||
2) | ||
#+BEGIN_SRC emacs-lisp | ||
(setq cquery-executable "/path/to/bin/cquery") | ||
#+END_SRC emacs-lisp | ||
If you need to expand =~= in the path, you can use =file-truename= like | ||
#+BEGIN_SRC emacs-lisp | ||
(setq cquery-executable (file-truename "~/cquery/build/release/bin/cquery")) | ||
#+END_SRC | ||
|
||
* Configuration | ||
cquery needs to know where to store index cache (=cquery-cache-dir=), which defaults to =.cquery_cached_index= in the project root. | ||
You may change it to an absolute path to have cache from different projects reside in the same directory. | ||
|
||
Many behaviors do not have correponding elisp variables and should be tuned via initialization options, such as the number of indexer threads, cache serialization format. They have good default values. | ||
Refer to [[https://github.com/cquery-project/cquery/wiki/Initialization-options][Initialization options]] and set =cquery-extra-init-params= for more customization. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
;; See https://github.com/cquery-project/cquery/wiki/Initialization-options | ||
(defvar cquery-extra-init-params '(:cacheFormat "msgpack")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
(require 'cl-lib) | ||
|
||
(defun cquery//enable () | ||
(when | ||
(and buffer-file-name | ||
(or (locate-dominating-file default-directory "compile_commands.json") | ||
(locate-dominating-file default-directory ".cquery"))) | ||
(lsp-cquery-enable))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
(configuration-layer/declare-layer 'lsp) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
(defconst cquery-packages '((cquery))) | ||
|
||
;; See also https://github.com/cquery-project/cquery/wiki/Emacs | ||
(defun cquery/init-cquery () | ||
(use-package cquery | ||
:commands lsp-cquery-enable | ||
:init | ||
;; Customize `lsp-project-whitelist' `lsp-project-blacklist' to disable auto initialization. | ||
(add-hook 'c-mode-common-hook #'cquery//enable) | ||
)) |