Skip to content

Commit

Permalink
Add +tools/cquery layer
Browse files Browse the repository at this point in the history
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
MaskRay committed Jan 30, 2018
1 parent 64cf9f5 commit e8d403c
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 0 deletions.
39 changes: 39 additions & 0 deletions layers/+tools/cquery/README.org
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#+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, ...)
- Diagnostics
- Completion with =company-lsp=
- Semantic highlighting
- See more on [[https://github.com/cquery-project/cquery/wiki/Emacs]]

* 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=).
There are other 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"))
8 changes: 8 additions & 0 deletions layers/+tools/cquery/funcs.el
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)))
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
:defer t
:init
;; Customize `lsp-project-whitelist' `lsp-project-blacklist' to disable auto initialization.
(add-hook 'c-mode-common-hook #'cquery//enable)
))

0 comments on commit e8d403c

Please sign in to comment.