Closed silgon closed 10 years ago
Hi,
the error comes from company-clang
, not company-irony
, are you sure you have the proper configuration? https://github.com/Sarcasm/company-irony/blob/29becb8824cacb1ea6f8c823d06ba65512c62e3d/README.md#configuration
You have to have irony-mode enabled in the buffer (take a look if "Irony" appears in the mode-line) and you have to have company-irony
present before company-clang
in company-backends
, see C-h v company-backends RET
to verify the latter, mine looks like this:
company-backends is a variable defined in `company.el'.
Its value is (company-irony company-elisp <...> company-clang ...)
...
Hi, sorry for disturbing you again =P It's actually weird, because as I said above in my computer at work is working ok the autocompletion (without taking into account the other problem I mention about the libraries). The important part of my code is as follows:
(require 'irony)
(add-hook 'c++-mode-hook 'irony-mode)
(add-hook 'c-mode-hook 'irony-mode)
(add-hook 'objc-mode-hook 'irony-mode)
(require 'company)
(add-hook 'after-init-hook 'global-company-mode)
(require 'company-irony)
(require 'company-c-headers)
(require 'company-anaconda)
(eval-after-load 'company
(progn
'(add-to-list 'company-backends 'company-c-headers)
'(add-to-list 'company-backends 'company-irony)
'(add-to-list 'company-backends 'company-anaconda)
))
(add-hook 'irony-mode-hook 'company-irony-setup-begin-commands)
When I press C-h v company-backends RET
a value like yours is displaying. But then again I have absolutely no idea where to start looking for. Because when do M-x company-irony
the menu is displayed. As far as I understand with the plugin company-irony you extend company-clang right? but then, both are running at the same time? also, when I do M-x company-clang
it only says cannot complete at point
but no error. So, I'm not sure it's that.
Ok, I just checked, the problem is a little bit weird (since I don't know the internal structure of company-mode). I commented the line '(add-to-list 'company-backends 'company-anaconda)
and now it's working correctly. It's really weird. What I can do is to load that company-backend
with a python hook, but I think the purpose of company-backends is not to do that. What do you think?
Could you just answer me and if you want close the issue since apparently is not related to this project anymore? Thanks.
As far as I understand with the plugin company-irony you extend company-clang right?
Not right, company-clang
is provided by default by company-mode
and rely on the Clang binary available on your system. company-irony
doesn't spawn the Clang binary but has a dedicated "server process" that should improve completion times and offers some other functionality in the future.
What I can do is to load that company-backend with a python hook, but I think the purpose of company-backends is not to do that. What do you think?
Yeah that shouldn't be necessary, company backends should usually be set all times but only the relevant ones will return something. I took a very quick look at company-anaconda
and I haven't seen anything that looked wrong.
Yes, it's kind of weird. I just know that if I de-activate the company-anaconda, the error is not appearing. But well, I cannot work properly with python with that problem.
Ok. Something weird happened. I changed the position of company-anaconda
and when I program in C it works ok.
(eval-after-load 'company
(progn
'(add-to-list 'company-backends 'company-anaconda)
'(add-to-list 'company-backends 'company-c-headers)
'(add-to-list 'company-backends 'company-irony)
))
Apparently anaconda was overriding the other modes (who knows why). Or that's what I thought. Then I started programming in python and I got the following:
Company: Back-end company-ropemacs error "Symbol's function definition is void: rope-completions" with args (candidates )
As if Irony is now overriding anaconda or something. Any ideas???
Btw. If I do M-x company-anaconda
I get the completions.
As if Irony is now overriding anaconda or something. Any ideas???
Not really but is your loading correct? Maybe you have to quote the progn? See the syntax here for example: https://github.com/company-mode/company-mode/issues/151
That's how I would write it:
(eval-after-load 'company
'(progn
(add-to-list 'company-backends 'company-anaconda)
(add-to-list 'company-backends 'company-c-headers)
(add-to-list 'company-backends 'company-irony)))
I just tried that way.... and It doesn't work with either python or C now =P. I throws the following error in C:
clang failed with error 1:
/usr/bin/clang -fsyntax-only -Xclang -code-completion-macros -x c++ -Xclang -code-compl
And the Following in python:
Company: An error occurred in auto-begin
Completion needs an inferior Python process running
Ok. Totally weird. I modified this:
(eval-after-load 'company
'(progn
(add-to-list 'company-backends 'company-irony)
(add-to-list 'company-backends 'company-c-headers)
(add-to-list 'company-backends 'company-anaconda)))
To:
(add-to-list 'company-backends 'company-anaconda)
(add-to-list 'company-backends 'company-c-headers)
(add-to-list 'company-backends 'company-irony)
Without any eval-afterload
and apparently it's working for both now =)
I'm not sure for anaconda but for irony-mode the error that appears:
clang failed with error 1:
/usr/bin/clang -fsyntax-only -Xclang -code-completion-macros -x c++ -Xclang -code-compl
has nothing to do with company-irony, instead it's the lack of company-irony that make company-mode select company-clang, and the message is printed by company-clang. I guess the situation with anaconda/rope is similar.
ok ok, it's good to know, just for general information, is there a way do deactivate one of the company-backends?
Yep, code not tested but something like the following should do it:
(eval-after-load 'company
'(setq company-backends (remq 'company-foo company-backends)))
I don't trust the eval-after-load 'company
anymore =P but it's good to know ;) merci encore!
Looking at your .emacs.d
you don't need the eval-after-load 'company
since you are requiring company
explicitly. But using the autoloads provided by company, irony, etc is usually better in order to reduce the loading time of Emacs.
De rien ;)
I know, but I lost one day on that, because the eval-after-load
with company
was not working as expected :/ .
C'est bizzare à Paris, il fait beau, après il fait trop chaud, après la pluit, après nuageux et frais.
Well, when using this construct:
(eval-after-load 'company
(progn
'(add-to-list 'company-backends 'company-anaconda)
'(add-to-list 'company-backends 'company-c-headers)
'(add-to-list 'company-backends 'company-irony)
))
The behavior is totally understandable. The progn, because it's not quoted, is evaluated immediately and evaluates to the last form which in this example is '(add-to-list 'company-backends 'company-irony)
. So the expression basically expand to:
(eval-after-load 'company
'(add-to-list 'company-backends 'company-irony))
Change the order of the items and the loaded backend will change as well to be the last.
Un peu de frais fait du bien !
Even when progn
was quoted it generated problems =P, but it doesn't matter now, I'm just happy because it works =)
One little thing first. This error is happening my home computer, while in my work computer I'm not having this problem. I'm using
irony-cdm-menu
in order to load the.clang_complete
file (for which i'm having an error because I don't get all the classes, namespaces and so on, but I'm going to refer it in another issue later). The problem is that when I'm adding some libraries in the.clang_complete
file, i'm getting an error in the minibuffer (code below), and therefore I'm not getting the autocompletion. Nonetheless, at the same point if I pressM-x company-irony
the menu is displayed with the options generated by the files loaded.