cursive icon indicating copy to clipboard operation
cursive copied to clipboard

Support for inline form evaluation + watching

Open mdedetrich opened this issue 10 years ago • 22 comments

Couldn't find an issue on this, but one of the (only) reasons for using an IDE like lighttable over cursive is its ability to evaluate clojure forms and display the results inline.

An even greater feature is the ability to watch certain forms, and whenever those forms are executed, you see the results of every s-expression that gets executed in those forms (this basically completely replaces debugging)

Here is a tutorial video for the evaluate expression https://www.youtube.com/watch?v=7YIaHyTdjTY And this one is for the watching feature https://www.youtube.com/watch?v=d8-b6QEN-rk (note that this is for javascript, but it works the exact same way with clojure)

Are features like this expected to be integrated into cursive?

mdedetrich avatar Jun 11 '14 06:06 mdedetrich

Yes, I'd like to, and I'm investigating options. IntelliJ doesn't provide a lot of infrastructure for painting over the top of the editor, but there are a couple of ways that might work. I can probably re-use some of the hint infrastructure, which are the pop-ups you sometimes see at the cursor. I'm not sure when I'll add this but I'd like to at some point. I actually like the instarepl painting of intermediate values, too, although that's probably trickier.

cursive-ide avatar Jun 11 '14 08:06 cursive-ide

Relates to (dupe of?) #133.

danielcompton avatar Jul 26 '15 01:07 danielcompton

To update this issue - IntelliJ 14 added support for inline painting of results. However the problem is that the results can only be a single line, and there's currently no good way to make them clickable to pop up an inspector window or anything like that. I'm discussing this with JetBrains, and I hope there'll be a good solution in IntelliJ 15.

cursive-ide avatar Jul 26 '15 09:07 cursive-ide

Cool, thanks for looking into this!

mdedetrich avatar Jul 26 '15 09:07 mdedetrich

Yes, I need this ability of evaluation + watching.

liango2 avatar Dec 04 '15 16:12 liango2

@cursiveclojure Any idea if this is easier with Intellij 15?

mdedetrich avatar Dec 06 '15 13:12 mdedetrich

Still interested in this feature, any updates?

mikeball avatar Jun 10 '16 00:06 mikeball

@cursive-ide the images in the documentation show that there is an option for inline evaluation. I tried CMD + ENTER at the end of the line but it doesn't seem to work :( image

pradeepcheers avatar Dec 06 '16 14:12 pradeepcheers

@pradeepcheers those are just static comments that show what the answer would be, there is no inline evaluation capability yet.

danielcompton avatar Dec 06 '16 20:12 danielcompton

To update this issue - IntelliJ 14 added support for inline painting of results. However the problem is that the results can only be a single line

For me, it will be enough. This thing really boosts productivity.

There already exists plugin which supports such thing for javascript's tests wallaby-js

Thanks

maksimr avatar Mar 06 '17 21:03 maksimr

@maksimr Yes, I love Wallaby! It's a fantastic tool.

I'm going to try adding this soon to see how it works. My plan is to collapse collection results to a line, truncated if necessary. In the case where a structure is truncated, I'll provide a gutter icon you can click to get a data structure explorer.

cursive-ide avatar Mar 06 '17 21:03 cursive-ide

@cursive-ide please add this! :) Light Table left a gap in the market. I just want to quickly see the results of my thinking inline.

theronic avatar Jan 09 '18 12:01 theronic

Any progress on this? :)

alexisvincent avatar Mar 09 '18 15:03 alexisvincent

It'd be so great

Nimamoh avatar Sep 07 '18 17:09 Nimamoh

@cursive-ide any updates?

coold avatar Aug 10 '20 17:08 coold

I would love love love to see this in Cursive, because I keep going back to Light Table to debug tricky algorithms and to teach Clojure.

I know Cursive is committed to IntelliJ right now, but it would be worth it to render the evaluated with inline results in a separate window, and in the long-term you'll probably need to do your own rendering.

theronic avatar Oct 04 '20 13:10 theronic

The Calva extension for Visual Studio Code shows the result of the entire expression as an inline comment after the code, but this totally misses the point of debugging intermediate steps, which is what Light Table lets you do, and greatly aids understanding in long threaded pipelines.

Here is a (crappy) macro I wrote to print intermediate results of a let-binding to logs to achieve something similar (using Specter :as S):

(defmacro let-spy
  [bindings & body]
  (let [pairs   (partition 2 bindings)
        rebound (into [] cat (S/transform [S/ALL (S/nthpath 1)] #(list 'log/spy :debug %) pairs))]
    `(let ~rebound ~@body)))

Surely this should be possible to do in the IDE given that Cursive already has to parse every expression?

theronic avatar Oct 05 '20 09:10 theronic

any update about this?

muhajirdev avatar Dec 24 '20 19:12 muhajirdev

I'm still curious about this! I'd love it.

classicrob avatar May 20 '21 02:05 classicrob

This is actually the next big new feature I'm working on, but it's stalled momentarily while I have to look at some other things. But, it's on the way.

cursive-ide avatar May 20 '21 02:05 cursive-ide

How is it going, is this feature incoming soon? =)

JacobGood1 avatar Nov 03 '21 16:11 JacobGood1

This plugin clj-extras-plugin can do inline code evaluation.

mikeananev avatar Apr 22 '22 10:04 mikeananev