Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Company backends should be grouped #2323

Closed
cpaulik opened this issue Jul 14, 2015 · 14 comments
Closed

Company backends should be grouped #2323

cpaulik opened this issue Jul 14, 2015 · 14 comments
Labels
Auto-completion Discussion stale marked as a stale issue/pr (usually by a bot)

Comments

@cpaulik
Copy link
Contributor

cpaulik commented Jul 14, 2015

I think company backends should be grouped and not pushed to the beginning of the list.

e.g. in python company-anaconda is pushed to the beginning of the company-backends which means all the other backends are never used even if company-anaconda can not find a completion candidate. It would however be great if company-dabbrev-code could be used in tandem with company-anaconda

Per default the value of company-backends-python-mode is

(company-anaconda
 (company-dabbrev-code company-gtags company-etags company-keywords)
 company-files company-dabbrev)

I think it should be

((company-anaconda
 company-dabbrev-code company-gtags company-etags company-keywords
 company-files company-dabbrev))

Unless I misunderstood how company works and this should be handled by company-anaconda

@nookiepl
Copy link

Is there way to override this variable in configuration? (excuse me, total emacs newbie, coming from VIM :D)

@zilongshanren
Copy link
Contributor

@cpaulik
If a company backend can't complete at the point, it will fallback to the next backend.
If you input something in the Python comments, it will use company-dabbrev backend.

Am I wrong?

@nookiepl
Copy link

Ok, with trial and error method I've added to dotspacemacs/config this

 (setq company-backends-python-mode '((company-anaconda
                                    company-dabbrev :with company-yasnippet)))

And it's working.

@zilongshanren, AFAIK, you are wrong (pythonic-emacs/company-anaconda#8).

@cpaulik
Copy link
Contributor Author

cpaulik commented Jul 15, 2015

@zilongshanren That is what I thought too, but according to one of the company-mode developers in the discussion at pythonic-emacs/company-anaconda#8 this is not the case

@cpaulik
Copy link
Contributor Author

cpaulik commented Jul 15, 2015

@zilongshanren actually you are partly correct. If point is in a region where a backend can not complete then it will move to the next backend. If however a backend could complete in theory but can not come up with any completion candidates then it will not choose the next backend.

@zilongshanren
Copy link
Contributor

@cpaulik @nookiepl
Thanks, I have read the discussion in (pythonic-emacs/company-anaconda#8), it is more clearer to me now.
But if we group company-anaconda and company-dabbrev, wouldn't it be too many candidates in the list?

@zilongshanren
Copy link
Contributor

@cpaulik I have modified my company backends to

(setq company-backends-c-mode-common '((company-c-headers
                                          company-ycmd
                                          company-dabbrev :with company-yasnippet)))

It's a big win, thanks.

@cpaulik
Copy link
Contributor Author

cpaulik commented Jul 18, 2015

After trying this for a while I actually think that there might be too many candidates mixed. It seems that the completion candidates are not ordered by backend which I see as a problem.

@cpaulik
Copy link
Contributor Author

cpaulik commented Jul 18, 2015

We could fix this by changing the company-transformers variable to use company-sort-by-backend-importance instead of company-sort-by-occurance.

@syl20bnr Do you think it makes sense to add a option for it or should this become the default if we decide to group backends?

@cpaulik
Copy link
Contributor Author

cpaulik commented Aug 19, 2015

@syl20bnr Have you had a chance to look at this? I've been using grouped backends sorted by backend importance for a while now and it works well. At least in python.

@syl20bnr
Copy link
Owner

I totally missed this issue, sorry about that.

None of the options listed above are OK to me but we can damage control by trying your last proposition to sort by backends. What I don't like at all is that it implies a lot of computing for nothing and it does not scale very well.

@syl20bnr
Copy link
Owner

With the sorting by backend importance, what about backends declared with :with ?

@cpaulik
Copy link
Contributor Author

cpaulik commented Aug 19, 2015

I see your point about the computation. The thing is that at least for python the other backends are hardly ever used since company-anaconda can often find no completion candidate but tries.

At the moment I use

    (setq company-backends-python-mode '((company-anaconda :with company-dabbrev :with company-yasnippet)))
    (setq company-transformers '(spacemacs//company-transformer-cancel
                                 company-sort-by-backend-importance))

If now get completion for variable names and module names that anaconda can not resolve but that I have used before. This is IMHO way superior to the current system.

I think that the main completion mode and company-dabbrev-code might be a good group.

As far as I can tell the backends are sorted properly only if :with is used.

@github-actions
Copy link

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Please let us know if this issue is still valid!

@github-actions github-actions bot added the stale marked as a stale issue/pr (usually by a bot) label Feb 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Auto-completion Discussion stale marked as a stale issue/pr (usually by a bot)
Projects
None yet
Development

No branches or pull requests

5 participants