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

Create session by sexpr passed to `Piggieback!` #222

Closed christoph-frick closed 7 years ago

christoph-frick commented 9 years ago

This allows e.g. running figwheel directly:

charlespwd commented 9 years ago

"A lot" is an understatement. THANKS x 1000 for this.

tpope commented 9 years ago

I have concerns about this shadowing the ability to use alternative piggieback invocations. But if the subject line is fixed I will merge and see who complains.

christoph-frick commented 9 years ago

@tpope i'll have a look, how i can better separate "Piggieback" and "piggiebacking".

tpope commented 9 years ago

Now that I think about it, we should probably just put this behavior on :Piggieback! (do ...). :Piggieback! is used to terminate a connection, but the behavior with an argument and a bang is currently undefined and thus available.

christoph-frick commented 9 years ago

@tpope i have shortened the subject, changed the behaviour over to Piggieback!, and added it to the docs.

christoph-frick commented 9 years ago

and this is how I learned how a:N works in vim... thanks for the review.

ghost commented 9 years ago

I tried it, evaluation works but K, [d and [ do not work (e.g. no source found) or

CompilerException java.lang.RuntimeException: Unable to resolve symbol: symbol in this context,  
compiling:(/private/var/folders/jg/0z60zn5s6yngbgy3_3nbv_g80000gn/T/form-i 
nit4554662321168274453.clj:1:1)
Error detected while processing function <SNR>134_Doc..fireplace#info..fireplace#evalparse:
line   12:
E605: Exception not caught: Clojure: class clojure.lang.Compiler$CompilerException   

if I press K .

christoph-frick commented 9 years ago

another problem is when cpp some broken code (e.g. (1 + 1)):

{'status': ['eval-error', 'done'], 'ex': 'class clojure.lang.ExceptionInfo', 'root-ex': 'class clojure.lang.ExceptionInfo', 'id': 'fireplace-ofnir-1441745140-1
5', 'session': ['741699a0-f978-4b6e-bb78-b92d9d9d1b9d'], 'err': 'ExceptionInfo #object[TypeError TypeError: cljs.core._STAR_e.getStackTrace is not a function] 
 clojure.core/ex-info (core.clj:4593)^@'}
tpope commented 9 years ago

Do those problems also manifest on the non-figwheel approach? I know K and the like worked at one point (provided cider-nrepl is set up) but not sure about the stacktrace.

ghost commented 9 years ago

Java based Clojure repl works.

tpope commented 9 years ago

I mean ClojureScript.

christoph-frick commented 9 years ago

i have cider in my profiles.clj, but i don't know how i would ensure, that it's working with fireplace. K works for me (tested with core and with user fn). [d gives me regular status message "Source not found" - no error. my error with i(1 + 1)<ESC>cpp happens with or without cider in my profiles.clj.

zamaterian commented 9 years ago

In a clojurescript. (with cider-nrepl as a plugin dependency) (figwheel 0.3.7)

K works :) Autocompletion works but is slow to start :) (uses youcompleteme) cpr also works

[d on a symbol resutls in : "Source not found"

gf on a symbol results in : CompilerException java.lang.RuntimeException: Unable to resolve symbol: symbol in this context, compiling:(/tmp/form-init5332223597722734736. clj:1:1) E345: Can't find file "navigation" in path

tpope commented 9 years ago

Not sure the status of the underlying source location op for [d but otherwise that looks pretty reasonable. The gf error is unfortunate but it's not designed to do what you're trying to do.

cirqueit commented 9 years ago

w/ cider-nrepl as a plugin dependency...

[d seems to work with fully qualified names (at least for core functions) cljs.core/defn shows source defn returns "Source not found"

K and [C-d work correctly for either.

tpope commented 9 years ago

That might mean a bug in the corresponding nrepl op, or it might mean we're passing the namespace incorrectly.

zamaterian commented 9 years ago

[C-d work on the require [sagsbehandler.components.spinner :as spinner]

but not on the aliased namespace : spinner/load-indicator
results in : Couldn't find source for spinner/load-indicator

And using omnicomplete is fairyslow ex:

(|) (cursor on | in insert mode C-x C-o takes aprox 3-4 seconds to show the complemention menu, any way of speeding this up ?

tpope commented 9 years ago

Sounds like the same as the previous comment. Anyone who wants to debug should read up on cider-nrepl's ops and try calling them with :echo fireplace#message({'op': 'whatever', ...}). If you can get something that's broken in fireplace to work with that direct invocation, I can help fix. Otherwise, it's probably on the cider-nrepl side.

gavocanov commented 8 years ago

This PR works really well with latest cider 0.10.0-SNAPSHOT and with Figwheel also, never before it's been such a pleasure working with cljs in vim.

Thnx a lot @christoph-frick

Any chance merging this in master?

jeffvandyke commented 8 years ago

Still figuring out how GitHub development works, but does this whole conversation mean that this pull request will soon get merged into master?

Deraen commented 8 years ago

I just tested this and got Figwheel repl working.

Doc works but Source doesn't, for some reason the source is printed on the browser console.

Fireplace is not using nrepl ops to check for :Source (or :FindDoc, :JavaDoc) but intead calling directly to cljs.repl/find-doc or cljs.repl/source: https://github.com/tpope/vim-fireplace/blob/49d3aca64df0ee6ea529c08850fb42344407bcd3/plugin/fireplace.vim#L1637-L1640

:Doc uses info op which is why it probably works: https://github.com/tpope/vim-fireplace/blob/49d3aca64df0ee6ea529c08850fb42344407bcd3/plugin/fireplace.vim#L1610

With boot-cljs-repl (Weasel), :Source etc. work so there is probably some difference in Figwheel cljs repl. Investigating.

Deraen commented 8 years ago

Output redirection is now fixed in Figwheel by @SevereOverfl0w: https://github.com/bhauman/lein-figwheel/pull/460

An alternative to this PR would be to add function to Figwheel which returns the correct env for Piggieback call in Fireplace: bhauman/lein-figwheel#457. I'm not sure which alternative is better.

jackrh commented 8 years ago

I finally got figwheel sidecar working with this PR.

Had to incorporate [[cider/cider-nrepl "0.13.0"]] into my lein plugins before K & [d would work as noted by others above.

SevereOverfl0w commented 8 years ago

This PR is no longer necessary as of https://github.com/bhauman/lein-figwheel/blob/master/CHANGES.md#058-fix-for-clojure-190-alpha12

christoph-frick commented 7 years ago

As stated above, this now works out of the box with 0.5.8. For those stumbling down this ticket in the future, here is a short rundown:

lein new figwheel app
cd app
lein repl

In the REPL:

(fig-start) ; this one comes from dev/user.clj

In Vim (in that app directory, open some *.clj* file):

:Piggieback (figwheel-sidecar.repl-api/repl-env)
devth commented 7 years ago
:Piggieback (figwheel-sidecar.repl-api/repl-env)

This hangs indefinitely (I let it run for about 30 min) in one of my larger projects.

It works in a small cljs project.

What are some steps to debug? Running (figwheel-sidecar.repl-api/repl-env) in a Clojure repl shows a huge map of stuff – what do I need to check for?

devth commented 7 years ago

Figured it out. If your project has multiple Figwheel builds you need to pass in the build ID:

:Piggieback (figwheel-sidecar.repl-api/repl-env "my-build")