-
-
Notifications
You must be signed in to change notification settings - Fork 645
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
Populate completions with metadata #3226
Conversation
@dgutov Can you take a look at the proposed changes as an expert in the API in question? |
Dmitry Gutov [2022-07-25 09:30:16] wrote:
The `meta -> (categiry . cider)` part seems sound.
[ Assuming it really says `category` instead. ]
Though I don't know if it's a good idea to create a category per completion
source. Perhaps @minad or @monnier have some opinion.
The completion source is probably not a good choice of "category" since
the category should describe the kind of things that are completed
rather than how we found those things.
But I can imagine sound reasons to want to pay attention to the "how",
e.g. because some completion styles work poorly with particular backends.
[ Reminds me that I suspect the notion of "category" will probably need to
grow some kind of hierarchy (or something) at some point. ]
Stefan
|
So can someone give me some examples of categories? I get this should be the implementation (e.g. CIDER), so what is it supposed to be? |
you can see that with describe-variable completion-category-defaults, by default it comes pre-populated with some categories. I agree with @monnier, but this is the only way that i know to get a finer control of the completion style, i.e. only apply a specific style for completions comming from cider. Eglot and lsp-mode follows the same idea: Eglot sets the category as eglot, and lsp-mode sets it to lsp-capf |
Fair enough. It'd be good if you also added something in the completion docs for |
Yes, I opened this PR following that rabbit role, but I think I will try to adress that problem in another PR. I will have to understand how the cider completion works in a deeper level. The interesting thing that I found is that the builtin emacs funcions for building capf's are kinda non-complient, like (complete-with-action) or (completion-table-dynamic). Or i'm undersanding stuff wrong, documentation is rare about this stuff. @minad Where do you find good documentation about capf's? Or the emacs manuals should be enought? |
The limitation is that
For Capfs the Emacs manual is not really a sufficient resource, but you can grep for example Capfs. My Cape package also comes with a bunch of simple Capfs which you could use as reference. I just looked at #3006 again. My recommendation is to remove the cider completion style completely: Lines 281 to 295 in b47fe53
Instead configure the |
I agree with @monnier, but this is the only way that i know to get a finer
control of the completion style, i.e. only apply a specific style for
completions comming from cider.
I'd need to know *why* you want the completion style to be different
when you use CIDER to be able to start thinking a bout what's
a better answer.
Is CIDER used only for one particular kind of completion (e.g. is it
only used to complete function names, or also file names, module names,
...)?
|
I use orderless as the completion style globaly, and I would like to keep it that way for most of the capf's, but some capf's don't play nicely with that, as #3006 and the last comment made by minad shows. And it's nice to have the option to set a different completion style in this category, orderless gives you the option of making custom completion engines. I could set |
Using a completion category here is valid. But you could also set globally: (setq completion-styles '(orderless basic) This is the recommended configuration from the Orderless configuration and will make sure that completion-table-dynamic works properly. |
The interesting thing that I found is that the builtin emacs funcions for
building capf's are kinda non-complient, like (complete-with-action) or
(completion-table-dynamic). Or i'm undersanding stuff wrong, documentation
is rare about this stuff.
These don't build "capf"s, they build completion tables.
CAPF = () -> (POS POS COMPLETION-TABLE)
…-- Stefan
|
This possibility was enabled by #3226 It can be seen in use in SystemCrafters/crafted-emacs#241 or https://clojurians.slack.com/archives/C0617A8PQ/p1696684010392119?thread_ts=1696618691.247989&cid=C0617A8PQ| It provides a better default experience for those using orderless or other newer styles.
This possibility was enabled by #3226 It can be seen in use in SystemCrafters/crafted-emacs#241 or https://clojurians.slack.com/archives/C0617A8PQ/p1696684010392119?thread_ts=1696618691.247989&cid=C0617A8PQ| It provides a better default experience for those using orderless or other newer styles.
This possibility was enabled by #3226 It can be seen in use in SystemCrafters/crafted-emacs#241 or https://clojurians.slack.com/archives/C0617A8PQ/p1696684010392119?thread_ts=1696618691.247989&cid=C0617A8PQ| It provides a better default experience for those using orderless or other newer styles.
This possibility was enabled by #3226 It can be seen in use in SystemCrafters/crafted-emacs#241 or https://clojurians.slack.com/archives/C0617A8PQ/p1696684010392119?thread_ts=1696618691.247989&cid=C0617A8PQ| It provides a better default experience for those using orderless or other newer styles.
This makes possible to override the cider completion style in
completion-category-defaults
orcompletion-category-overrides
.This will simplify the workarounds needed to make cider work with
orderless
set as the "global" completion style. like seen in #3019 (comment). With this pull request, the following will work.(setq completion-category-defaults '((cider (styles basic)))
The code is basicaly the same as the function returned by
completion-table-dynamic
, but simplified since we don't need to checkswitch-buffer
, since is alwaysnil
in this context. And when(eq action 'metadata)
, return the metadata.completion-table-dynamic, in minibuffer.el
The implementation in the pull request
I've been using this implementation for 2 days with
advice-add
, experienced no problems.Let me know if its needed to add any documentation around this .
Before submitting the PR make sure the following things have been done (and denote this
by checking the relevant checkboxes):
eldev test
)eldev lint
) which is based onelisp-lint
and includescheckdoc
, check-declare, packaging metadata, indentation, and trailing whitespace checks.Thanks!
If you're just starting out to hack on CIDER you might find this section of its
manual extremely useful.