Sarcasm / company-irony

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

Completion not working in some cases #11

Open fehmud opened 9 years ago

fehmud commented 9 years ago

Sometimes, company-irony does not list any candidates, even when headers are present and the code compiles flawlessly. How could this be troubleshooted? Thank you.

Sarcasm commented 9 years ago

Are you sure you are using the company-irony backend?

You can look in the modeline that it is irony and not company-clang or something else that is used. You can also call M-x company-irony RET manually to be sure you are using the proper backend.

Do you have the compile options properly setup? M-x irony-cdb-menu RET?

fehmud commented 9 years ago

Sorry, I had forgotten to say that I had checked all the obvious configurations, including checking whether irony-server was running. Anyway, it turned out that I had a broken configuration and an old version of irony (the stable version that is available on Melpa Stable, that is). Anyway, I managed to fix everything. Now, I have only a couple of suggestions:

Thanks for your assistance.

fehmud commented 9 years ago

Another problem is that company-irony on Melpa Stable pulls the old version of irony, and if users remove the old version of irony, package-initialize will fail to enable company-irony if the load-path doesn't contain the new irony yet. This is another problem that company-irony had in my configuration. Therefore I removed company-irony from the packages handled by the package manager and installed it by hand.

fehmud commented 9 years ago

But users could think that company-irony is stuck, therefore an informatory message -- like "Starting irony-server, please wait..." -- would help;

Another idea would be to start the server in the C Mode hook, therefore Irony should offer an irony-start-server command to run there.

Sarcasm commented 9 years ago

when company-irony completes the first time, there is a long delay. I suppose that that is because it must start the server. But users could think that company-irony is stuck, therefore an informatory message -- like "Starting irony-server, please wait..." -- would help;

Starting the server shouldn't take long. What takes time is usually the first parsing of the file, when the precompiled preamble hasn't been generated yet. But this timing isn't specific to the irony-server start, it will happen in some other situation and irony doesn't really know actually, so it's difficult to provide a message.

the implementation of irony--locate-server-executable only prints a message when there is an error. But messages get lost in the Messages buffer when you restart Emacs and all files gets reopened by Desktop Mode. Therefore, irony--locate-server-executable should raise an error instead, or at least use warn instead of message.

In one of my local commit I have changed the function to signal an error. Elisp code calling the function will have the possibility to handle the failure gracefully.

also, I can't recall where I have read that company-irony works only if it comes before company-clang. If indeed this is the case, then this is another check that company-irony could perform the first time that it runs.

That's one of the "core principle" of company. I don't want to check this kind of things in company-irony because it is error prone. The company-backends variable is non-trivial, I don't want to perform some checks on it. company-diag and company's mode-line message should inform the user about the selected backend.

Another problem is that company-irony on Melpa Stable pulls the old version of irony, and if users remove the old version of irony, package-initialize will fail to enable company-irony if the load-path doesn't contain the new irony yet. This is another problem that company-irony had in my configuration. Therefore I removed company-irony from the packages handled by the package manager and installed it by hand.

I'm not sure to understand. Isn't that a bug in the package dependency management?

Another idea would be to start the server in the C Mode hook, therefore Irony should offer an irony-start-server command to run there.

Offering a way to start irony-server in a mode hook in addition to the first time it is needed may be a good idea. We will see but as I said earlier, in my local work I already changed the function a little bit and the functions that need irony-server will normally already handle this error gracefully.

fehmud commented 9 years ago

I'm not sure to understand. Isn't that a bug in the package dependency management?

Rather than a bug, it seems that such situations must be handled on a case by case basis (see C-h f package-load-list). I am not sure about how to handle this, therefore I am voting to leave things unchanged.

We will see but as I said earlier, in my local work I already changed the function a little bit and the functions that need irony-server will normally already handle this error gracefully.

Then please let me know as soon as you will have uploaded the new code.

Thanks for your assistance.