Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add +tools/cquery layer #10236

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions layers/+tools/cquery/README.org
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.
2 changes: 2 additions & 0 deletions layers/+tools/cquery/config.el
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"))
4 changes: 4 additions & 0 deletions layers/+tools/cquery/funcs.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
(defun cquery//enable ()
(condition-case nil
(lsp-cquery-enable)
(user-error nil)))
1 change: 1 addition & 0 deletions layers/+tools/cquery/layers.el
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(configuration-layer/declare-layer 'lsp)
10 changes: 10 additions & 0 deletions layers/+tools/cquery/packages.el
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)
))