Closed wuliuxiansheng closed 7 years ago
It is documented that there are separate include paths for system and user includes. You probably have them set differently I guess?
I set them separately, one is company-c-headers-path-system and the other one is company-c-headers-path-user. The even interesting thing is that I can use #include “”
to include system headers with perfect completion.
I’m having trouble understanding your problem, can you send me a failing test case?
I mean I set the paths for system header files and user header files, but I can use #include “”
to do completion for system header files which is supposed to be working with user header files and the when I use #include <>
to do completion for system header files, the completion is not working well. I will generate a test case for you.
This is an example I made. The structure of the test case is:
and I already add these paths to company-c-headers-path-system
and company-c-headers-path-user
respectively. In main.cpp, I can use #include ""
to include both system header files and user header files with proper completion, but when I use #include <>
, the completion for system header files is not working.
Sorry I can't replicate this. Added a test case, see the issue-19 branch. Please try this and let me know if it fails for you.
Thanks for your reply. What should I do with these two test files? I installed company-c-header package via MELPA.
Yeah you'll need to clone the repo, install Cask, and then do make test
. (Very brief instructions I know). If all goes well you should see something like this:
$ make test
cask exec emacs -Q --batch -f batch-byte-compile company-c-headers.el
cask exec ert-runner
Company backend ’company-clang’ could not be initialized:
Company found no clang executable
................
Ran 16 tests in 0.036 seconds
I did this test and got similar output as yours. What does this mean?
It means that company-c-headers is working correctly. I would suggest either a) play with the test case to try to replicate your problem, or b) look for other libraries which are contributing/causing the problem. In particular you should check other company backends - try disabling them and see if you can replicate the problem. Sorry I can’t offer more concrete suggestions.
Thanks for your reply. I kind of find the problem. Once I disable company-semantic, then the completion for system header files are working properly but I still can use #include “”
to do completion for system files which is supposed to work only for user header files. Is this designed to be this way? Also what could company-semantic affect company-c-headers to work properly?
Not sure I understand the question, but what could be happening is that company-semantic
is higher precedence than company-c-headers
, which means that it is actually doing the completion instead of company-c-headers
. I don’t use company-semantic
though so I can’t really say.
I think I figured it out. I add company-c-headers to company-backends before company-semantic and the problem is solved.
Congratulations on working out the problem.
If there are some system header files in include/directory/, when I type in
#include <direc>
, there will be some candidates showing up. After I select directory/, there is no completion candidates. However, this kind of completion is working if using user header file format#include "direc"
and all candidates will show up and I can press Tab to do selection with#include "directory/"
, and then more candidates in this folder can show up for me. It seems that system header files completion is different from user header files completion.