-
-
Notifications
You must be signed in to change notification settings - Fork 653
Add company-cider backend #1910
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
Add company-cider backend #1910
Conversation
I think that'd be better. Some people might be using a mixture of backends and this would affect them. |
doc/code_completion.md
Outdated
(add-hook 'cider-mode-hook #'company-mode) | ||
``` | ||
|
||
To enable CIDER-specific company backend, add the following hooks: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a CIDER-specific
use the following code (you're actually adding hook functions to the hooks)
(add-hook 'cider-mode-hook #'company-cider-make-exclusive) | ||
``` | ||
|
||
When `company-mode` is thus enabled, it will receive completion information |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd keep the original paragraph before this code and add some explanations about the different behaviour afterwards - with a link to "Fuzzy candidate matching" (or you can just move that section here).
cider-interaction.el
Outdated
(defun company-cider (command &optional arg &rest ignored) | ||
"`company-mode' completion backend for CIDER." | ||
(interactive (list 'interactive)) | ||
(cl-case command |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not use pcase
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mindlessly copied from some other backend. Point taken.
Looks good to me overall. Apart from my small remarks you should mention this in the changelog. |
I would like anyone to try this out to verify it doesn't only work on my setup:). Will rebase when ready. |
OK, I'll try to source you some testers from Twitter as I'm short on time to testing myself right now. |
If Might a mode-local variable be a better idea? |
To be honest, I've stolen the idea of a buffer-local variable from company-eclim. If you say that it is better to make the variable mode-local, so be it. |
@xiongtx Is this what you have in mind? |
It's part of CEDET, and not used too widely. On the other hand, changing the buffer-local value of |
I'll defer to the author of |
Thanks for chiming in, Dmitry! |
Not a problem. But also see the last comment in the original issue. If what I'm suggesting is right, it should lead to a smaller, less disruptive change. |
@alexander-yakushev Seems no one volunteered to test this, but we can merge this non-the-less. Squash and rebase and ping me when this is good to go. |
doc/code_completion.md
Outdated
additional package [company-flx](https://github.com/PythonNut/company-flx). | ||
This is powered internally by [flx](https://github.com/lewang/flx). | ||
```el | ||
(add-hook 'cider-repl-mode-hook #'company-cider-enable-backend) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be cider-company-enable-backend
This is not working for me. I tried the exclusive config to make sure nothing else was interfering in my setup but I did not get any completion results nor errors?
Using latest packages on melpa |
I have tested the code, it works. But will break the behavior of mixed backends users. Like grouped backends with (defun my-company-add-backend-locally (backend)
"Add a backend in my custom way.
\(my-company-add-backend-locally 'company-robe\)
"
(if (local-variable-if-set-p 'company-backends)
(add-to-list 'company-backends `(,backend :with company-yasnippet))
(add-to-list (make-local-variable 'company-backends)
`(,backend :with company-yasnippet))
)) |
@stardiviner Apparently, @dgutov was correct after all (to nobody's surprise) suggesting to use a custom completion style rather than a custom backend. I have rewritten the PR. Could you please test if this solution doesn't break your setup? @julienfantin Thanks for pointing out a mistake! Could you please try if the current version works for you? |
Sorry, right about what? I never said a custom backend won't work with fuzzy-matching. There are such third-party backends for other languages already. I suggested the completion-styles approach because it takes less code, and because it might work with |
Correct about it being a "better" way, if it actually will help stardiviner's usecase.
|
Cool. This UI has a few peculiar behaviors, such as moving point to the position where disambiguation is required, which probably won't work with fuzzy. But still, having the basics work is a good result. |
cider-interaction.el
Outdated
;; Fuzzy completion for company-mode | ||
|
||
(defun cider-company-compliment-candidates (string table predicate point) | ||
"Return Compliment candidates as is, without filtering them." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just one thing about the use of compliment in the names - this calls into the middleware which uses compliment for clj connections and cljs-tooling for cljs connections. Don't think cljs-tooling supports the fuzzy matching, so some mentions of this might be useful.
Looks OK to me. I wonder if we shouldn't move all the completion stuff to a dedicated file as there's already quite a lot of completions-related code. |
cider-company-compliment-candidates | ||
"CIDER backend-driven completion style.")) | ||
|
||
(defun cider-company-enable-fuzzy-completion () |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There should be a matching disable command I guess.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is supposed to be put on a hook and enables itself per-buffer. Does it still warrant a disable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, it's not a big deal but I can imagine some peoople will use this without a hook and it's generally a good idea to have a way to undo the effect of enabling this.
@alexander-yakushev It works with the |
Guess this is in a good enough shape now. Thanks, @alexander-yakushev! |
#1909 follow-up.
This patch adds
company-cider
backend that for the most part calls directly to the already existing CIDER functions. An update to docs was also made to describe how to enable the backend.I've made a function that sets
company-cider
a sole completion backend. Is it OK? Maybe it is enough to dropcompany-capf
from the list?Regarding the docs, I also request comments. I took the liberty to drop the mentions of company-flx, but I feel there is a better way to explain the new setup.