jasongilman / proto-repl

A Clojure Development Environment package for the Atom editor
https://atom.io/packages/proto-repl
MIT License
563 stars 50 forks source link

Output to nREPL or Another Atom Window? #266

Open shoxter opened 7 years ago

shoxter commented 7 years ago

I love the proto-repl; however, it's quite frustrating being forced to examine the output of block or selection executed code in the actual proto-repl window. The reason this is frustrating is because we can't open up a proto-repl in another atom window and send code to that repl from our code window (in other words, have two atom windows -- one for code and another for the repl).

I tried using an nRepl session and connected the proto-repl to the nRepl to see if my output would print to the nRepl and it doesn't.

Am I missing something here? Is there a better solution that having to split a window or constantly hide and show the proto-repl in order to get a full screen of code?

lucasdf commented 6 years ago

Any luck on this @shoxter ? I am trying to do the same.

shoxter commented 6 years ago

@lucasdf Unfortunately, no. I have two identical monitors mounted right next to each other, so I end up expanding the Atom window across two screens and have the workspace split between the two -- one monitor with code the other with the nRepl.

I've stopped using the proto-repl because of this inconvenience.

lucasdf commented 6 years ago

oh, that's very annoying. May I ask what you end up using instead? Have you stopped using Atom for clojure or have you just stopped using proto-repl?

shoxter commented 6 years ago

I honestly haven't found a decent Repl solution for Atom. Within Atom (which I still use for Clojure development), I mainly resort to spyscope and debux for debugging.

I've tried to use Light Table, Cursive within IntelliJ, and Sublime.

I just don't like the experience as much in any of those IDE's unfortunately. :\

I'd be interested to hear what tools you're using for Clojure development?

lucasdf commented 6 years ago

I guess we are on the same boat. I have tried Cursive and Spacemacs but I was not very productive using them. I have been using Atom for Clojure. I enable proto-repl for its autocomplete feature, but I keep its tab hidden instead of keeping it side-by-side. Other than that I have been using a regular repl in the terminal.

shoxter commented 6 years ago

It appears so. It's very unfortunate. I love Clojure, but there doesn't seem to be any type of modern development environment for it that is complete. You have to makeshift your own environment from multiple utilities and even then it's sub-par to the tools available to a JAVA developer IMO.

With that being said, our entire back-end is Clojure and I still wouldn't trade it for any other language that I'm aware of.

sashton commented 6 years ago

@shoxter @lucasdf I think this is more of a limitation of Atom and nRepl. Atom doesn't AFAIK do inter-window communication. Maybe there's some way to hack it with IPC, but I seriously doubt it would work out too well. And nRepl sessions don't share stdout. So connecting to an already running terminal REPL session won't make output from Atom show up in the other REPL.

But, despite that, there is a way to do what you want, if you are willing to include a minor hack to proto-repl in your init.coffee:

fs = require 'fs'
replLogFile = '/tmp/replOut.txt'
protoRepl.onDidConnect ->
  protoRepl.repl.replView.defaultAppender = protoRepl.repl.replView.appendText
  protoRepl.repl.replView.appendText = (text, waitUntilOpen=false)->
    fs.writeFileSync(replLogFile,text+"\n",{"flag":"a"})
    protoRepl.repl.replView.defaultAppender(text, waitUntilOpen)

This is just wrapping the repl output function, making it log to a file, then also doing the normal atom repl output. You are then free to tail the replLogFile in a terminal on another monitor.

Note that the code as written won't work with the Ink repl because the Ink repl has separate functions for info,error, etc; and it was easy to only override the single appendText function. This sample code could be expanded to override those functions in a similar way to support the Ink REPL.