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
make selecting a key from a clojure hashmap a cider function. #3231
Comments
This sounds to me like a feature to be implemented in https://github.com/alexander-yakushev/compliment (which cider-nrepl and cider.el use):
Compliment is extensible by design (via Not super sure if Compliment, by default, does eval the completion context (which is side-effectful). https://github.com/clojure-emacs/clj-suitable which is part of CIDER uses a side-effectful approach to
LMK how this sounds. Cheers - V |
Are you suggesting using compliment functionality instead of something like emacs "completing-read" to offer key choices to the user? Cider would still be responsible for evaluating the Clojure map to get the keys right? |
A normal stack for tab completions (just like the completions you get for defn/var/class names) would be cider, company-mode, cider-nrepl, Compliment. I'm indicating that the standard place to offer a new kind of completion would be said stack - that way we leverage lots of existing code and avoid reinventing UIs.
Cider passes a "completion context" to cider-nrepl. That is forwarded to Compliment. |
@vemv do you have any idea how to iteratively test extending the compliment library? As in, if I correctly create a custom compliment defsource . How do I test that it works? |
There are a couple things you can do:
Hope it helps! |
I'm suggesting a feature to make selecting a key from a Clojure hashmap slightly easier by having a shortcut in cider to call clojure.core/keys and produce a list that the user can select from. The current way I do this is just like that, by printing the result of calling keys on the map like so:
then copying and pasting that key over the call to keys, like so.
then deleting the printed keys.
This works fine, but I think this is a common enough task that having a shortcut would be nice. In the code below the
vector would be an emacs list that contains the key choices and the "*" is the cursor that can go up and down. When the cursor is on a value, you could select that key, and it gets replaced. Here are roughly the steps I imagine:
The first pass of this feature could generate the key list by evaluating the map. From there it might be worth considering trying to pull from other sources like the spec registry or all identifiable keys in the project.
If this idea seems sound, I'll work to submit the pull request with the functionality. If not, let me know why.
Thanks!
The text was updated successfully, but these errors were encountered: