tpope / vim-fireplace

fireplace.vim: Clojure REPL support
https://www.vim.org/scripts/script.php?script_id=4978
1.75k stars 139 forks source link

Add Doc ability for special forms and namespaces #279

Closed trptcolin closed 7 years ago

trptcolin commented 8 years ago

I've had this code sitting around on my laptop forever and figured I should at least open a PR in case it's useful to others. This makes it so Doc works on special forms like if, quote, etc. - and also namespaces.

jgdavey commented 7 years ago

This is interesting. This handles the case where the cider-nrepl op "info" is either not available or insufficient.

It looks like the handler for op "info" could be more complete, including, for example, the special forms that you include here. It's currently looking for a "file" key to determine if the nrepl branch worked.

For example, see the difference between map and if:

[{'status': ['done'], 'file': 'jar:file:/path/to/.m2/repository/org/clojure/clojure/1.8.0/clojure-1.8.0.jar!/clojure/core.clj', 'doc': 'Returns a lazy sequence consisting o
f the result of applying f to
  the set of first items of each coll, followed by applying f to the
  set of second items in each coll, until any one of the colls is
  exhausted.  Any remaining items in other colls are ignored. Function
  f should accept number-of-colls arguments. Returns a transducer when
  no collection is provided.', 'static': 'true', 'name': 'map', 'added': '1.0', 'id': 'some-id-for-session', 'session': 'ba06cf10-ca03-485c-b726-fad074b3506a', 'ns': 'c
lojure.core', 'column': 1, 'resource': 'clojure/core.clj', 'line': 2618, 'arglists-str': '([f] [f coll] [f c1 c2] [f c1 c2 c3] [f c1 c2 c3 & colls])'}]
[{'status': ['done'], 'id': 'some-id-for-session', 'doc': 'Evaluates test. If not the singular values nil or false,
  evaluates and yields then, otherwise, evaluates and yields else. If
  else is not supplied it defaults to nil.', 'url': 'http://clojure.org/special_forms#if', 'name': 'if', 'special-form': 'true', 'session': 'ba06cf10-ca03-485c-b726-fad074b3506a'
, 'forms-str': '  (if test then else?)'}]