-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Description
tl;dr Jump to the bottom to see the demo.
"cquery is a highly-scalable, low-latency language server for C/C++/Objective-C". There are uses on indexing Chromium, LLVM projects, and Linux kernel. It provides similar features with venerable rtags, like finding definitions/references.
https://github.com/MaskRay/ccls libclang + Clang C++
https://github.com/cquery-project/cquery libclang
You can take this issue as a "seeking for help". There are many pieces need customizing (cquery.el lsp-mode lsp-ui) to provide a kinda satisfying code assistant UI. spacemacs is used by many and to me a suitable place to combine these efforts. I leave some notes at https://github.com/jacobdufault/cquery/wiki/Emacs but my elisp-fu is incapable to create a robust layer.
I'd also like to know if there is interest to incorporate lsp-mode through which we can provide a unified interface for C++, Rust and many other languages. I have used rls (Rust) and cquery (C++) and many features can and should be shared and be provided by a common library (lsp-mode lsp-ui). cquery.el provides a LSP plugin for cquery and it also has some extensions not included in LSP:
;; emacs-ccls https://melpa.org/#/ccls
(ccls-xref-find-custom "$ccls/base")
(ccls-xref-find-custom "$ccls/callers")
;; No "$ccls/derived", use lsp-goto-implementation from lsp-mode instead
(ccls-xref-find-custom "$ccls/vars")
;; Alternatively, use lsp-ui-peek interface
(lsp-ui-peek-find-custom 'base "$ccls/base")
(lsp-ui-peek-find-custom 'callers "$ccls/callers")
;; ...... emacs-cquery https://melpa.org/#/cquery
;; the cquery counterparts are similar
(cquery-xref-find-custom "$cquery/base")
(cquery-xref-find-custom "$cquery/callers")
(cquery-xref-find-custom "$cquery/derived")
(cquery-xref-find-custom "$cquery/vars")
;; Alternatively, use lsp-ui-peek interface
(lsp-ui-peek-find-custom 'base "$cquery/base")
(lsp-ui-peek-find-custom 'callers "$cquery/callers")
;; ......There are still useful features that are missing or can be improved in cquery.el. And it is also nice to learn from users using other code assistants to know what can be improved generally about cquery.
I might be biased regarding rtags because I am a contributor of cquery. What bothered me a lot when I was using rtags was its query performance Andersbakken/rtags#1007
See also:
cquery.el: https://github.com/cquery-project/emacs-cquery/blob/master/cquery.el
lsp-mode https://github.com/emacs-lsp/lsp-mode
lsp-ui https://github.com/emacs-lsp/lsp-ui
A brief list of what can be improved
- semantic highlighting More granular symbol kinds for semantic highlighting jacobdufault/cquery#239
- Visualization of
$cquery/typeHierarchyTree - With
(setq cquery-extra-init-params '(:enableComments 2 :cacheFormat "msgpack"), comments are not nicely rendered in eldoc [hover] Display the last MarkedString when there are multiple. emacs-lsp/lsp-mode#224 - Polish before publishing jacobdufault/cquery#30 some entries lean to VSCode, but many apply also to Emacs
- Some cases where libclang is incapable to provide all desired information "Go to Definition" does not work for enumeration used as type of non-type template parameter jacobdufault/cquery#252
- Something possible technically but entails a complicated implementation Hover over variable (esp. a constant) could show its initial value jacobdufault/cquery#260
- Niche codelens-style argument names in calls jacobdufault/cquery#85 support
workspace/executeCommandjacobdufault/cquery#283
If you speak Chinese, I've written an article introducing cquery and my configuration http://maskray.me/blog/2017-12-03-c++-language-server-cquery



