company-irony icon indicating copy to clipboard operation
company-irony copied to clipboard

Completion is not triggered after member access operators

Open Pouya-moh opened this issue 6 years ago • 5 comments

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?

Pouya-moh avatar Jul 17 '19 08:07 Pouya-moh

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?

Sarcasm avatar Jul 21 '19 12:07 Sarcasm

Thanks for swift response.

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

It returns ("" . t)

Is this the expected return?

Pouya-moh avatar Jul 22 '19 09:07 Pouya-moh

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))

Sarcasm avatar Jul 22 '19 09:07 Sarcasm

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?

Pouya-moh avatar Jul 24 '19 12:07 Pouya-moh

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.

Sarcasm avatar Jul 24 '19 12:07 Sarcasm