emacs-ycmd
emacs-ycmd copied to clipboard
#include path completion doesn't work
Do I need to do some special configuration here? It seems like I only get identifier completion, not semantic completion. @Valloric - anything a ycmd frontend has to be careful about here?
I can't think of any special configuration you should need. That feature certainly works well for me. Does semantic completion seem to work well everywhere else in the file?
#include path completion is actually a part of the general completion engine... which is technically composed of the trio of identifier completer engine, ultisnips completer engine and filepath completer engine. The general completion engine is turned on for every filetype.
Querying ycmd for completions after #include " or #include < will produce include-completion through the filename completion engine... it will query the ycm_extra_conf.py file for compilation flags and will extract the ones that point to header include directories. These folders will be queried for header names (or subfolders).
Yes, header completion works, but only after #include <. When using #include " company-ycmd--prefix returns nil because of the condition (not (company-in-string-or-comment))
See #141
@prtv is absolutely right, and his patch plugs that hole. Does that fix things up for you, @r4nt?
Works in general now, but doesn't seem to list all possible completions after / #include "dir1/a (works, shows all completions starting with "a" in "dir1") #include "dir1/ (doesn't work, not giving any completions)
I use ycmd with compile_commands.json and just I discover that ycmd should complete include statements. I always thought that it was not supported and I used company-c-headers within a "company group backend" to have this feature. I give a try and I am not able to make it working because when trying to complete "#include <vec" ycmd gives: "RuntimeError: No completions found; errors in the file?" Is this feature working? Do I need some special configuration?
Include completion should work. #include <vec should give you results.
Also #include "dir/ should complete correctly.
Both cases work for me.
@r4nt Are you still encountering this issue?
@damienrg As @ptrv says, this should work. Can you post your *ycmd-server* buffer contents (or at least any parts that might be relevant to this issue)?
I created a repository to ease testing.
With this configuration I only have the following messages when trying to complete on #include <vec :
2017-02-15 22:44:18,590 - INFO - Received completion request
2017-02-15 22:44:18,591 - DEBUG - Using filetype completion: False
@damienrg I checked out your test repository and indeed I couldn't complete the vector include. I got the same error from the server: RuntimeError: No completions found; errors in the file?
Looking at the debug-info with M-x ycmd-show-debug-info RET I could see that I had no other compile flags than ycmd/ycmd/clang_includes.
It looks like ycmd doesn't see the standard includes paths. There is a section about this in the documentation: https://github.com/Valloric/YouCompleteMe/#completion-doesnt-work-with-the-c-standard-library-headers
There is a workaround in that section which describes how to get the system include path and to add them to the compile flags.
After adding the system include paths to the flags, completion on #include <vec works.
Hope this helps
I will try it but I do not understand why do I need to add includes while completion is working here:
std::vector<int> v;
v. // completion work here
To complete ycmd must know where vector is.
You reported that completion works in https://github.com/abingham/emacs-ycmd/issues/140#issuecomment-279936063. Are you using a compilation database? If not, have you set include path in your ycm_extra_conf.py?
@d0k apropos, can we enable clang-include-fixer for YCM nowadays without too much hassle?
@damienrg My default .ycm_extra_conf.py also adds the system includes to the ones found in a compilation database. So yes, I am using both like in this conf: https://github.com/abingham/emacs-ycmd/blob/master/test/resources/.ycm_extra_conf.py
@ptrv Indeed it works if I do the workaround mentioned in the ycmd documentation (I just used your function as it does the job). Anyhow, it is annoying that we still have to use a workaround for a 4 years old bug.