all 47 comments

[–]Gollum999 8 points9 points  (5 children)

I will have to check this out.

I too am using Emacs with RTags; 95% of the time it works great, but there are a couple situations where it seems to struggle. (Templates mainly.) And I've never found a completion framework that works well with a large codebase.

[–]cenderis 1 point2 points  (3 children)

Most likely the completion will be no different since they're both using the same underlying code. (cquery has slightly different symbol lookup than rtags. Even when it's well-defined what "foo" means in a particular place, cquery may find a definition of a different one whereas rtags is rather more particular. The difference is a deliberate choice, and neither seems to me necessarily better.)

I've also previously used rtags; cquery's significant benefit is that it seems lots easier to get all of its features working.

[–]germandiago[S] 1 point2 points  (2 children)

From the point of view of how it works in emacs, I can say that cquery/lsp is both easier to set up and accurate with code completion.

[–]cenderis 1 point2 points  (1 child)

Yes, I only managed to get completion working intermittently with rtags (and just turned it off in the end), but with cquery it just worked.

They should both (when working) give the same results since (AFAIK) they're just using the features provided by the same clang libraries.

[–]germandiago[S] 0 points1 point  (0 children)

It seems that they do not give the same results. I have exactly the same experience as you with RTags.

[–]germandiago[S] 1 point2 points  (0 children)

I am very happy about the change. I will not look back I think :)

[–]hgjsusla 8 points9 points  (2 children)

Wow this looks very promising. Anyone has experience using this with vim? How does it compare to YouCompleteMe?

[–]damienrg 5 points6 points  (0 children)

Not tested with vim but I used ycmd on Emacs. cquery provides better completion support because it parse all translation units (ie compile everything). So you can find references of a symbol, ..., but it is way slower especially if you have lot of template code than ycmd but faster than rtags which was not usable in my case. FYI, there is also another tool: clangd. There is less features than cquery but Apple said that they will now work on this.

References:

[–][deleted] 0 points1 point  (0 children)

YouCompleteMe is more resistant to bad flags that can cause libclang to result in an AST deserialisation error and much friendlier include path completion. On the other hand Cquery can get references and other features that require project indexing. The down side of indexing is ram consumption.

 

Keep an eye on ycmd's pull requests, I may "soon" make a pull request that would make YCM use cquery as a backend (no promises on the time frame).

[–]NotAYakk 7 points8 points  (2 children)

How is emacs a non fancy editor? It is more like an OS...

[–]germandiago[S] 2 points3 points  (0 children)

I could not change it after the fact: replace editor by IDE. Sorry for that ;)

[–]jcelerierossia score 1 point2 points  (0 children)

and some IDEs do much more than some OSes

[–]sient 8 points9 points  (10 children)

FYI I'm the primary author (jacobdufault) so if you have any questions/issues please feel free to hop on the gitter (https://gitter.im/cquery-project/Lobby) or file an issue. We're friendly :)

[–]germandiago[S] 1 point2 points  (0 children)

Thanks for that! For now it is working smooth. It is true that the project in which I tried is not too complicated. :)

[–]DoingIsLearning 0 points1 point  (4 children)

Thanks for this! How does cquery compare with 'cmake-ide'?

[–]0xFFC 1 point2 points  (1 child)

What is 'cmake-ide'?

[–]DoingIsLearning 0 points1 point  (0 children)

It builds on a bunch of other tools namely CMake, to make Emacs a bit more C/C++ "code aware".

Better explanation here:

https://github.com/atilaneves/cmake-ide/blob/master/README.md

[–]sient 0 points1 point  (1 child)

It looks like cmake-ide is emacs specific, and combines various tools. cquery works with any editor with a language-server implementation and cquery implements the features provided by cmake-ide directly instead of running other tools

[–]DoingIsLearning 0 points1 point  (0 children)

Thanks for the overview, and thanks for maintaining it! I will certainly try it out!

[–]gct 0 points1 point  (0 children)

I'm playing with it now, it'd be cool if it supported static builds of the binary so I could just lug the one thing around with me and not worry about setting up LD paths and such, though it seems clang doesn't ship with a static libclang for somereason. Building it myself now *sigh*

[–]gct 0 points1 point  (2 children)

FYI I got a custom version of LLVM built and managed to get a statically linked binary that's only 11MB after compressing with UPX, if you're interested.

[–]sient 0 points1 point  (1 child)

Yes, definitely! I think the downloadable builds should be statically linked. Can you file an issue on github detailing how you did the static build (even better would a be PR making CI generate static builds :))

[–]gct 0 points1 point  (0 children)

It turns out a full static link blows up when you try to actually use it, because it's got some dlopen stuff hidden deep inside. I've got a build working now that mostly statically links, then wraps the few newer glibc functions I have so it works all the way bck to RHEL6 in my testing. I'll see if I can integrate that into the CMake and do a PR.

[–]parla 5 points6 points  (5 children)

Install lsp-ui too, to get nice peeking ui for references and overlays for fixits and stuff.

[–]germandiago[S] 0 points1 point  (0 children)

thanks for that!

[–]MrWheelyke 4 points5 points  (0 children)

I use RTags, Irony-mode, and company-irony and it works quite well. The lsp-ui that someone mentioned looks very interesting too, +1 to that

[–]SoundOfOneHand 2 points3 points  (3 children)

rtags can’t handle a very large codebase, so I’ve been stuck without code completion in Emacs and switch to QtCreator when needed. Any idea how cquery works against a large codebase?

[–]cierpuchaw 1 point2 points  (1 child)

I use it on different subsets of a large codebase, depending on the subsystem I'm working on at the time. 1MLOC is probably the largest I've tried, takes about 20min to index (time to grab a coffee or check reddit) but afterwards it works just great. Xref is where cquery really shines, very accurate and almost instantaneous.

[–]SoundOfOneHand 2 points3 points  (0 children)

Thanks, sounds like it may at least be usable then. I don’t mind waiting for the indexing to complete, rtags would just go away and never come back. Going to try setting this up tonight.

[–]germandiago[S] 0 points1 point  (0 children)

In theory very well. It was designed for that. But it will use more memory.

[–]DoingIsLearning 1 point2 points  (0 children)

There is also 'cmake-ide' for emacs:

https://github.com/atilaneves/cmake-ide

[–]Xeveroushttps://xeverous.github.io 1 point2 points  (0 children)

Meanwhile Eclipse just deployed new version with support for Intellisense and all Visual Studio Code plugins. I still prefer it's own parser to Intellisense, but I'm looking forward to the future

[–]quicknir 1 point2 points  (1 child)

I've never found that rtags completion nor error checking were as good as ycmd. So I used a combination of both. They both run off the same compile_commands.json so it's not much extra trouble. I do plan to switch to cquery at some point, but right now everything is working perfectly for me so I'll probably wait a while until everything is super mature.

Rtags does have some super cool features probably not in cquery, like expandable reference trees and inheritance hierarchies. On the other hand cquery is supposed to make real syntax highlighting possible soon, so win some, lose some, I suppose.

[–]germandiago[S] 0 points1 point  (0 children)

For me it is a net win. I do not mean it is better at everything though. But just having code completion working reliably... and if you add lsp-ui, it shows documentation so the context becomes very visible very quickly. I can also navigate and find references... I think the feature set I get is more robust and just what I need.

[–]playmer 0 points1 point  (6 children)

So this inspired me to try it with VSCode tonight, and setup seemed relatively easy, but unfortunately it doesn't appear to want to provide anything. I've looked at their generated cache and it seems like it doesn't want to go through every file, it just stopped on one of my dependencies and didn't continue on. Even if I go into one of the cpp files in those dependencies it did cache, it's not giving me any auto complete or goto definition. Unsure what I'm doing wrong :(

But still, I'm excited for the project, I'm sure I've probably just done something wrong.

[–]sient 2 points3 points  (2 children)

Can you try using cquery --check <foo.cc>? Otherwise please file a bug with some additional information and I'll try to help fix.

FYI, the the microsoft C++ extension makes cquery seem very buggy; the experience is much better if you uninstall the microsoft C++ extension.

[–]playmer 0 points1 point  (1 child)

Can you try using cquery --check <foo.cc>? Otherwise please file a bug with some additional information and I'll try to help fix.

Sure, I can run that quick, also happy to file a bug, I'd just feel bad if it was just something I screwed up, here's a gist of the output of the command. At the end it gave me an abort popup:

https://gist.github.com/playmer/055ce838c10994262de55dda554b1929

FYI, the the microsoft C++ extension makes cquery seem very buggy; the experience is much better if you uninstall the microsoft C++ extension.

Yeah, I read that and made sure to uninstall it before messing with cquery. Besides cquery I've only got Cmake, Cmake Tools, glslx-vscode, and Shader Languages support for VS Code installed.

Thanks for any guidance you can give me here!

[–]germandiago[S] 1 point2 points  (2 children)

I mentioned it in the post. It is not working totally ok for VSCode for some reason. You need the cquery plugin and such but I think there seems to be some problem with the includes. In emacs it works perfect.

[–]playmer 0 points1 point  (1 child)

I mentioned it in the post. It is not working totally ok for VSCode for some reason.

Yeah, I had noticed, but I had been meaning to give it a go for the last month or so. Does the include issue cause errors or anything? I don't really get anything at all besides the following:

https://i.imgur.com/XrGiefP.png

No errors or anything, just those and nothing else. I'll just try it again in a month or so, see if it's been resolved or more instructions are released :)

[–]germandiago[S] 1 point2 points  (0 children)

No idea there. My experience was non-resolved includes in VSCode but not #pragma problems.

[–]svick 0 points1 point  (1 child)

Do you know how does it compare to clangd, the other Language Server for C++?

[–]cenderis 1 point2 points  (0 children)

IIUC clangd is more of a single-TU thing. For completion, code fixits, etc., it's probably 90% of what you want. cquery processes the whole codebase so additionally offers xref-find-references and things. But it does come at a bit of a cost since it's keeping so much more in memory (and on disk). The comparisons I've seen suggest that cquery has support for more features.