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

alchemist-company prevents other company modes #66

Closed
semanticart opened this issue Apr 15, 2015 · 5 comments
Closed

alchemist-company prevents other company modes #66

semanticart opened this issue Apr 15, 2015 · 5 comments

Comments

@semanticart
Copy link
Contributor

I'm fairly new to emacs, so apologies if this isn't terribly descriptive. I'm on 24.4.91.1 and alchemist-20150407.55 fwiw.

I'm using company mode w/ global-company-mode. My init.el looks something like this

(use-package elixir-mode :ensure)
(use-package alchemist :ensure)

(use-package company :ensure)
(add-hook 'after-init-hook 'global-company-mode)

In non-elixir files, company-mode's company-backends look like this

company-backends is a variable defined in `company.el'.
Its value is (company-bbdb company-nxml company-css company-eclim company-semantic company-clang company-xcode company-cmake company-capf
              (company-dabbrev-code company-gtags company-etags company-keywords)
              company-oddmuse company-files company-dabbrev)

These allow completion of keywords, words in open buffers, etc. It is very useful.

When in an elixir file, company-backends looks like this

company-backends is a variable defined in `company.el'.
Its value is (alchemist-company company-bbdb company-nxml company-css company-eclim company-semantic company-clang company-xcode company-cmake company-capf
                   (company-dabbrev-code company-gtags company-etags company-keywords)
                   company-oddmuse company-files company-dabbrev)

where alchemist-company has been inserted into the beginning. But unfortunately if a match doesn't come up in alchemist-company, it does not list options from the other backends.

I would love to use alchemist-company and still failover to the other backends.

Am I doing something wrong? Any advice, or is this just not possible?

@rranelli
Copy link
Contributor

I'm not very familiar with company myself (just switched after a long time with ac-mode) but I will try to take a look at this problem as soon as possible.

@jtmoulia
Copy link
Contributor

@semanticart company-mode should continue to the next backend if the current backend doesn't return a match. So! something is broken. I don't know if it'll matter, but what value do you have alchemist-project-compile-when-needed set to?

Hey @rranelli -- I was playing with company-mode the other day and can look into this.

@semanticart
Copy link
Contributor Author

Thanks, guys. I'm not setting that variable anywhere.

alchemist-project-compile-when-needed is a variable defined in alchemist-project.el'.
Its value is nil`

setting it to t does not appear to change anything

@jtmoulia
Copy link
Contributor

Looking through the doc for the company-backends var (super useful), turns out I was wrong when I said company-mode should go to the next backend of the current backend doesn't return a match. It looks like company will only go to the next backend if the current backend returns nil as the completion prefix.

If it's in an elixir buffer, alchemist's company backend uses alchemist-help--exp-at-point to get the prefix, which will return whatever string is under the cursor. So, in an elixir buffer it won't move on to the next backend.

A simple solution: you can use the interactive command company-other-backend to skip the current backend. It's not as easy as company doing it for you, but if you bind it to a key it shouldn't be too bad.

Alternatively the alchemist backend's prefix command could have more logic for when to return nil, but unless it actually checks candidates (bad. would block.) it won't do what you want.

@semanticart
Copy link
Contributor Author

Thanks @jtmoulia. I'll probably take the reverse approach and remove alchemist-company from the backend list and invoke it via keypress.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants