-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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 ccls/cquery (language server) to c-c++ layer #10134
Comments
Adding a bunch of people who may be interested in better Emacs user experience of C/C++ or general LSP support. @scturtle @jiegec @topisani @danielmartin @DeltaEvo @acowley Sorry if that bothers you... For integration of lsp-mode lsp-ui, please contact @vibhavp @sebastiencs cquery @jacobdufault |
I don't particularly use Spacemacs, only vanilla GNU Emacs, so I don't know what the requirements are for including a package in a particular layer. I think cquery.el is already pretty stable and provides a lot of functionality so it can be a good candidate for inclusion. Also, with cquery everything is in one place, and it implements a well-known protocol. Without LSP it is typical to have to install several specialized packages to have an IDE experience (rtags for code navigation and irony-mode/ycm for code completion, for example). |
I currently maintain my rust language server layer here: https://github.com/bkchr/rustrls |
If you want to have a try, I have a personal lsp-cquery layer with some customizations. Agree with @bkchr. If there is a lsp layer with common configurations, it would be easier to integrate lsp client into each language layer. |
I have also cleaned my lsp-mode/lsp-ui based config. The cquery specific stuff is very simple now.
|
Created #10211 and emacs-cquery is now in Melpa |
@MaskRay I spent a few hours on a train journey today comparing your cquery and my-code layers with the existing c-c++ layer, paying attention to how ycmd and rtags are integrated in the latter. Have refactored some of the functionality into a reasonably coherent set of additions to the lsp layer with some of the common keybindings, a new cquery layer and some minimal additions to the c-c++ layer in a new branch forked from spacemacs/develop. Think it's fairly close, but certainly not suitable for a a single PR -- not sure if it's of any use to you, or where to go with it from here, but it's here; |
Awesome work! I left some notes. I hope you can make it a PR to supersede mine. |
from here: #10236
|
@cormacc
I do not see options for major mode (SPC m j or SPC m h) for cquery layer, or (SPC m T) for lsp. Also I get a lot of errors from flycheck that I guess raised by cquery. |
@arefasvadi Here's my config -- I include lsp layer explicitly to override some defaults... I enable cmake layer as well, but just for CMAKELISTS syntax support. i.e. without enabling cmake-ide support, as that has some functionality that overlaps/conflicts. Though it would be nice at some stage to use cmake-ide to pick up changes to cmakelists.txt and regenerate compile_commands.json, using a persistent build pool directory, and configure query to look there rather than in the project root. Assuming you can disable the rest of the cmake-ide functionality (rtags etc.). Not useful enough for any of my current projects to tackle it just now though --- sounds like it would take a while to figure out :) I just regenerate compile_commands.json manually every now and then.
|
Time passes, I no longer use cquery and have a different plan. I made a fork on Apr 1 (sarcastically!) and renovated it with improvement of import pipeline last weekend and clang+llvm C++ API this weekend. It has only 3 git submodules and the removal of loguru is also in the works. If you are curious enough and intend to give it a try: https://github.com/MaskRay/ccls/wiki/Getting-started If you have at least 16GB memory and are brave enough to compile clang+llvm from source: https://github.com/MaskRay/ccls/wiki/Build#link-against-clangllvm-libraries-compiled-from-source Caution: C++17 and Clang C++ API are tough to tame on old distributions. |
Why? And what's the plan? |
Since #11242 was merged we can close that issue |
Yes, thanks everybody for participating in this. It was a huge piece of work ❤️! |
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:
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
$cquery/typeHierarchyTree
(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#224workspace/executeCommand
jacobdufault/cquery#283If you speak Chinese, I've written an article introducing cquery and my configuration http://maskray.me/blog/2017-12-03-c++-language-server-cquery
The text was updated successfully, but these errors were encountered: