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

Fix company backends setting #125

Closed
wants to merge 2 commits into from
Closed

Fix company backends setting #125

wants to merge 2 commits into from

Conversation

gilbertw1
Copy link
Contributor

@gilbertw1 gilbertw1 commented Jun 26, 2017

After doing a bit of debugging I noticed the the :company-backend setting is not correctly adding individual backends, but is instead always appending the entire list of backends.

For example, after executing the following line:

 (set! :company-backend 'scala-mode '(ensime-company company-yasnippet)))

The company-backends var for scala mode will look like:

'((ensime-company company-yasnippet)
   backend1 backend2 backend...)

What I would expect to happen would be that the value would look like:

'(ensime-company company-yasnippet backend1 backend2 backend...)

I've updated the def-setting! so that it will add these values into the existing flat structure, and now has the additional benefit preventing duplicate backends from being added to the list. Additionally, I've included in this pull request the removal of the explicit add of the ensime-company backend, since it's already added when ensime-mode is enabled.

@hlissner
Copy link
Member

hlissner commented Jun 26, 2017

This was intentional. Company backends are OR'ed, i.e. backend1 OR backend2 OR backend3. So later backends won't run unless earlier ones fail.

Backends in sublists are merged together. i.e. (backend1 UNION backend2) OR backend3, which I think is desirable.

However, I do see a possible improvement to :company-backend to allow:

;; prepends multiple symbols
(set! :company-backend 'scala-mode 'ensime-company 'company-yasnippet)
;; company-backends: (ensime-company company-yasnippet ...)

;; pushes a sublist
(set! :company-backend 'scala-mode '(ensime-company company-yasnippet))
;; company-backends: ((ensime-company company-yasnippet) ...)

Additionally, I've included in this pull request the removal of the explicit add of the ensime-company backend, since it's already added when ensime-mode is enabled.

I can't say I'm a fan of (ensime-company-enable) (which ensime-mode uses to set up company):

  1. It only adds company-ensime. My setting adds (company-ensime company-yasnippet).
  2. it rebinds TAB to ensime-company-complete-or-indent (i.e. whether the user likes it or not).

I think it's better to leave it to :company-backend. Ensime can be told not to interfere with (setq ensime-completion-style nil) with no ill effects to completion in general.


Thanks for pointing this out, but I can't accept the PR.

@gilbertw1
Copy link
Contributor Author

Ah my bad, thanks for the response!

This totally explains the behavior I was seeing. RTFM :)

@gilbertw1 gilbertw1 closed this Jun 26, 2017
hlissner added a commit that referenced this pull request Jun 28, 2017
+ Autoload ensime after scala-mode
+ Don't let ensime initialize company; let :company-backend do it
+ Fix void-variable imenu-auto-rescan error caused by
  ensime--setup-imenu.
hlissner added a commit that referenced this pull request Jun 28, 2017
(set! :company-backend MODES &rest BACKENDS)
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 1, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants