randomphrase / company-c-headers

Auto-completion for C/C++ headers using Company
GNU General Public License v2.0
76 stars 9 forks source link

system header files completion issue #19

Closed wuliuxiansheng closed 6 years ago

wuliuxiansheng commented 6 years ago

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.

randomphrase commented 6 years ago

It is documented that there are separate include paths for system and user includes. You probably have them set differently I guess?

wuliuxiansheng commented 6 years ago

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.

randomphrase commented 6 years ago

I’m having trouble understanding your problem, can you send me a failing test case?

wuliuxiansheng commented 6 years ago

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.

wuliuxiansheng commented 6 years ago

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.

randomphrase commented 6 years ago

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.

wuliuxiansheng commented 6 years ago

Thanks for your reply. What should I do with these two test files? I installed company-c-header package via MELPA.

randomphrase commented 6 years ago

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
wuliuxiansheng commented 6 years ago

I did this test and got similar output as yours. What does this mean?

randomphrase commented 6 years ago

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.

wuliuxiansheng commented 6 years ago

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?

randomphrase commented 6 years ago

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.

wuliuxiansheng commented 6 years ago

I think I figured it out. I add company-c-headers to company-backends before company-semantic and the problem is solved.

randomphrase commented 6 years ago

Congratulations on working out the problem.