Sarcasm / company-irony

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

Completion is not triggered after member access operators #45

Open Pouya-moh opened 5 years ago

Pouya-moh commented 5 years ago

Hi. First thanks for awesome package. I am having some trouble with company-irony: After typing . for class members or :: for namespace the company menu is not shown.

In my settings I have company-clang-begin-after-member-access set to 1, however, with company-irony backend it seems it is not respected. If I remove the company-irony backend and use the company-clan then . and :: triggers completion.

I opened an issue in company repo (https://github.com/company-mode/company-mode/issues/534) but I was suggested to post it here and I think it is right.

The relevant part of my setup reads as follow:

(with-eval-after-load 'company
  (add-hook 'c++-mode-hook 'company-mode)
  (add-hook 'c-mode-hook 'company-mode))

(use-package company-c-headers
  :ensure t)

(use-package company-irony
  :ensure t
  :config
  (setq company-backends '((company-c-headers
                company-dabbrev-code
                company-irony))))

(use-package irony
  :ensure t
  :config
  (add-hook 'c++-mode-hook 'irony-mode)
  (add-hook 'c-mode-hook 'irony-mode)
  (add-hook 'irony-mode-hook 'irony-cdb-autosetup-compile-options))

Any idea?

Sarcasm commented 5 years ago

What happens if you do M-: (company-irony-prefix) RET after . or ::? If this function returns something, then irony is okay, and something is tampering with it, maybe company-dabbrev-code?

Pouya-moh commented 5 years ago

Thanks for swift response.

What happens if you do M-: (company-irony-prefix)RETafter.or::`?

It returns ("" . t)

Is this the expected return?

Sarcasm commented 5 years ago

Yeah, I think it is okay, it would expect nil or 'stop if irony could not do anything. Can you try to set just irony as a backend?

  (setq company-backends '(company-irony))
Pouya-moh commented 5 years ago

Interestingly enough, keeping company-irony as the only backend solves the issue. Am I going to miss something important in terms of completion if I keep the backends to company-irony only?

Sarcasm commented 5 years ago

The thing is, company interrogates the backends, and stop on the first one that can handle the request, other backends in the list aren't tried.

So you have to order the list from the most to the least specific backend.

That is, either:

  (setq company-backends '((
                company-irony
                            company-c-headers
                company-dabbrev-code
))))

Or:

  (setq company-backends '((company-c-headers
                company-irony
                company-dabbrev-code
))))

dabbrev-code is very generic.

And company-c-headers, I don't know.