Sarcasm / company-irony

company-mode completion back-end for irony-mode
119 stars 11 forks source link

company-irony obstructs other company backends #7

Closed farva closed 9 years ago

farva commented 9 years ago

Having company-backends set to (for example) (company-c-headers company-irony...) works fine, completing #include statements and code completion with irony. But having company-backends set to (company-irony company-c-headers) leads to only irony code completion. #include statements are not completed.

farva commented 9 years ago

So there is nothing wrong with company-irony - it was just me not understanding company-backends semantics. If a backend reports it is applicable in current context (the prefix command), then company does not continue to the next backend, no matter if it returned completion candidates or not (the candidates command). Specifically, company-c-headers is applicable only in #include statements, so trying completion anywhere else, will fail through company-c-headers to the next backend. On the other hand, company-irony is applicable anywhere in a c-like buffer, so it will never fail though it to the next backend.

What is needed to do is what company states in the documentation - group company-irony with any other backend (company-c-headers can be left out of the group, but should come before it in company-backends).

farva commented 9 years ago

So there is nothing wrong with company-irony - it was just me not understanding company-backends semantics. If a backend reports it is applicable in current context (the prefix command), then company does not continue to the next backend, no matter if it returned completion candidates or not (the candidates command). Specifically, company-c-headers is applicable only in #include statements, so trying completion anywhere else, will fail through company-c-headers to the next backend. On the other hand, company-irony is applicable anywhere in a c-like buffer, so it will never fail though it to the next backend.

What is needed to do is what company states in the documentation - group company-irony with any other backend (company-c-headers can be left out of the group, but should come before it in company-backends).

Sarcasm commented 9 years ago

I'm not sure if company-irony isn't at fault somewhere but I followed the company-backends documentation to the letter, it says:

prefix: The back-end should return the text to be completed. It must be text immediately before point. Returning nil from this command passes control to the next back-end. The function should return stop if it should complete but cannot (e.g. if it is in the middle of a string).

In this case, maybe #include "| shouldn't be considered inside a string.

Honestly I think the best thing to do would be to complete header files in company-irony, since I have almost all the information to do it, apart from the system header search paths.

So what is your solution exactly?