-
Notifications
You must be signed in to change notification settings - Fork 38
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
Function arglists #26
Function arglists #26
Conversation
I don't quite get the rationale behind this. The arglist can (and should) be retrieved separately when needed IMO. That's what we do in Emacs and there's no problem to do so in vim. |
Doesn't vim-fireplace show a documentation popup for completion? That's where we show the arglist and other docs. Arglists are often too long and squeezing them into candidates can be cluttering. |
Passing more data will also introduce an additional decoding overhead. |
Well, Vim doesn't really have a "documentation popup". Completion plugins, like YouCompleteMe, can display info for the selected candidate in a separate preview window. But it looks like even the preview window can only display data retrieved from complete function. There is no separate API to retrieve the info when user changes the selection. |
That makes two of the frontends that want this behavior (see also clojure-emacs/cider-nrepl#176). It is possible to make this thing optional, so that tagged version returns arglists, docs or both. Although there might be some drop in performance. Juho, are you one of the vim-fireplace maintainers? If not, whom should I cast into this thread for the discussion? |
//cc @tpope |
I have also some terrible memories of some arglists not being properly encodable in bencode, therefore we started sending them around as strings. Don't recall if we ever fixed this or not in CIDER and I don't have much time to investigate this. There's one more thing to be considered - ideally changes like this should be synced with |
So the ElDoc middleware sends a string and CIDER parses it? vim-fireplace could do that too, I guess. |
Actually the middleware returns a list of list of strings for each arglist if memory serves. Parsing this on the client was impossible at the time, as we were reading the Clojure code with Elisp's reader. Maybe @expez's P.S. You can examine the message exchange in |
We can have some option in the middleware op to select just certain keys from the metadata. |
Btw. here are the changes for fireplace to support this: tpope/vim-fireplace@master...Deraen:master I'm thinking I'll open PR there when we get this solved. I was testing this with fireplace and I don't see any performance problems even when completing with empty prefix, which results in around 800 suggestions. Adding a option to cider-nrepl complete operation sounds like a good idea to me. |
Since I support Android as first-class platform, there are performance considerations there, so this behavior certainly won't become non-conditional. I would still like to know first if a more sensible solution, like ElDoc, is possible in Vim. @bbatsov I would rather not rely on cider-nrepl to select the necessary keys from the result maps. There are projects that use Compliment directly (at least, Nightcode) and I don't want them to build additional middleware on top of completion. It is better to pass another option in |
Fine by me. |
Vim's completion provides room in the drop down menu next to each candidate for an additional annotation, which suits the arglist perfectly. This means I need all of them, not just the one for the selected function. Since it's for display, I would also greatly favor them in string form, as I don't have a Clojure printer available. Limitations of the completion system mean that to automatically display docs, I would need them included as well. Personally this is not a high priority for me. I can tell you my eval solution includes arglists and docs and I've never hit on a performance problem. |
Would the following actions suit everyone:
|
Lists of strings. The rest sounds good to me. |
Does the approach I took to pass the options map to tag-fn seem acceptable? Example output: user=> (compliment.core/completions "assoc" {:ns 'user, :tag-candidates true, :tag-candidates-doc true, :tag-candidates-arglists true})
({:arglists ("[map key val & kvs]" "[map key val]")
:candidate "assoc"
:doc "clojure.core/assoc\n([map key val] [map key val & kvs])\n assoc[iate]. When applied to a map, returns a new map of the\n same (hashed/sorted) type, that contains the mapping of key(s) to\n val(s). When applied to a vector, returns a new vector that\n contains val at index. Note - index must be <= (count vector).\n"
:ns "clojure.core"
:type :function} |
I'd drop the |
Everything looks fine, but I agree with @bbatsov about the naming. Perhaps it would be better to have a single additional option, say |
Sounds good. On 23 April 2015 at 18:51, Alexander Yakushev [email protected]
Best Regards, |
16222db
to
595641b
Compare
Changes implemented. |
595641b
to
a913331
Compare
Great! One last thing I would ask you to do is to squash and force-push the commits into one or two or three, whichever seems more fit. Sorry for being so demanding:) |
Options map contains ns.
:extra-metadata option can be used to add additional fields (:arglists, :doc) to the response maps.
a913331
to
dede166
Compare
And done. I would have demanded the same if this was my project :) |
Our buddy Travis says all is well and I can't deny it! |
Cast @laurentpetit. |
@alexander-yakushev many thanks for the mention! |
Yeah, I forgot to say thanks to @Deraen for implementing this and bearing with me and Bozhidar ;) |
I don't know about Emacs but with Vim-fireplace I would very much like to display the arglist for each completion result.
This change enchances tag-fn to assoc arglists to the result if the var has one.