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

improve the output format of print-var-documentation #319

Open chriswatrous opened 5 years ago

chriswatrous commented 5 years ago

This PR improves the output of the print-var-documentation command.

current output:

image

new output:

image

The current code also depends on the stdout coming back to through the repl connection, which may not always happen. (It doesn't with the shadow-cljs repl I'm using.) The new code uses with-out-str to get the doc output through the return value.

I also added an allSessions option to NReplConnection.sendCommand to make it easier to switch all sessions to ClojureScript when using shadow-cljs or piggyback. This is needed because the new doc command uses displayInRepl: false and so the command goes to cmdSession instead of session. Users can define commands like this in their init.coffee / init.js to switch between Clojure and ClojureScript repls:

atom.commands.add('atom-workspace', 'proto-repl-custom:switch-to-shadow-cljs-app-repl', () =>
  protoRepl.executeCodeInNs('(shadow.cljs.devtools.api/nrepl-select :app)', {allSessions: true}));

atom.commands.add('atom-workspace', 'proto-repl-custom:exit-cljs-repl', () =>
  protoRepl.executeCodeInNs(':cljs/quit', {allSessions: true}));