Skip to content
An Atom plugin to integrate with Socket-REPL over Clojure and ClojureScript
Branch: master
Clone or download
Latest commit a4db9f9 Mar 3, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
docs
integration Fixed test (new CLJ renders different order) Feb 3, 2019
keymaps Starting re-structure Aug 28, 2018
lib
repl-tooling @ 062ccbc Submodule update Feb 2, 2019
scripts Prepare-release changes. Dec 21, 2018
src/chlorine Merge pull request #47 from sogaiu/select-network-text-fields-on-focus Mar 4, 2019
styles Style Oct 13, 2018
.gitignore Submodule update. Jan 29, 2019
.gitmodules Using repl-tooling as a submodule Sep 26, 2018
.travis.yml Shut up, travis! Nov 10, 2018
CHANGELOG.md Version bump Feb 2, 2019
LICENSE.md Initial commit (copied from simple-git).Initial commit (copied from May 31, 2016
README.md Fixed non-vim bindings on README (closes #35) Jan 26, 2019
package-lock.json Version bump to 0.0.9 Jan 30, 2019
package.json
project.clj
shadow-cljs.edn Remove :source-paths and :dependencies from shadow-cljs.edn Jan 29, 2019

README.md

Chlorine

Build Status

Cl + Atom = Chlorine

Socket-REPL integration with Clojure and ClojureScript with Atom.

This package requires Ink to work. Install it on Atom package manager

Usage:

Fire up a clojure REPL with Socket REPL support. With shadow-cljs, when you watch some build ID it'll give you a port for nREPL and Socket REPL. With lein, invoke it in a folder where you have project.clj and you can use JVM_OPTS environment variable like:

JVM_OPTS='-Dclojure.server.myrepl={:port,5555,:accept,clojure.core.server/repl}' lein trampoline repl

You can use lein trampoline repl or lein repl: both work (but I found that using trampoline uses less memory. Notice that trampoline will not work with nREPL).

With clj, you can run the following from any folder:

clj -J'-Dclojure.server.repl={:port,5555,:accept,clojure.core.server/repl}'

Or have it in :aliases in deps.edn. (For an example with port 50505 see https://github.com/seancorfield/dot-clojure/blob/master/deps.edn, then you can run clj -A:socket.)

Then, you connect Chlorine with the port using the command Connect Clojure Socket REPL. This package works with lumo too, but you'll need to run Connect ClojureScript Socket REPL.

When connected, it'll try to load compliment and org.clojure/tools.namespace (for autocomplete and refresh). Then you can evaluate code on it, and it'll render on a block decoration below the line.

Keybindings:

This package does not register any keybinding for you. You can define whatever you want. Some suggestions could be:

If you use vim-mode-plus:

'atom-text-editor.vim-mode-plus.normal-mode[data-grammar="source clojure"]':
  'g f':          'chlorine:go-to-var-definition'
  'ctrl-d':       'chlorine:doc-for-var'
  'space c':      'chlorine:connect-clojure-socket-repl'
  'space l':      'chlorine:clear-console'
  'shift-enter':  'chlorine:evaluate-block'
  'ctrl-enter':   'chlorine:evaluate-top-block'
  'space space':  'inline-results:clear-all'
  'space x':      'chlorine:run-tests-in-ns'
  'space t':      'chlorine:run-test-for-var'

'atom-text-editor.vim-mode-plus.insert-mode[data-grammar="source clojure"]':
  'shift-enter': 'chlorine:evaluate-block'
  'ctrl-enter': 'chlorine:evaluate-top-block'

If you don't use vim bindings:

'atom-text-editor[data-grammar="source clojure"]':
  'ctrl-, y':       'chlorine:connect-clojure-socket-repl'
  'ctrl-, e':       'chlorine:disconnect'
  'ctrl-, k':       'chlorine:clear-console'
  'ctrl-, f':       'chlorine:load-file'
  'ctrl-, b':       'chlorine:evaluate-block'
  'ctrl-, B':       'chlorine:evaluate-top-block'
  'ctrl-, i':       'chlorine:inspect-block'
  'ctrl-, I':       'chlorine:inspect-top-block'
  'ctrl-, s':       'chlorine:evaluate-selection'
  'ctrl-, c':       'chlorine:source-for-var'
  'ctrl-, d':       'chlorine:doc-for-var'
  'ctrl-, x':       'chlorine:run-tests-in-ns'
  'ctrl-, t':       'chlorine:run-test-for-var'

How to work with ClojureScript

For now, it only works with Shadow-CLJS or Lumo.

With Lumo, you fire up lumo with lumo -n 3322 to start a socket REPL on port 3322 (or any other port), then connect Chlorine with "Connect ClojureScript Socket REPL".

With Shadow-CLJS, after watching (or after starting a server, or anything that starts a socket REPL) you connect with "Connect Clojure Socket REPL", then run the command "Connect Embedded ClojureScript REPL". Then you can run code on .cljs files too.

WARNING!

This package is still in ALPHA! Expect breakages!

So far, what's working:

  1. Connect to Socket REPL from Clojure
  2. Connect a ClojureScript REPL (only shadow-cljs supported for now)
  3. Disconnect (and handling when a REPL goes away)
  4. Doc for vars (Clojure and ClojureScript)
  5. Auto complete with Compliment
  6. Simple auto complete for ClojureScript
  7. Refresh for Clojure code with clojure.tools.namespace

What is still crude:

  1. There are no configurations for what to run before and after refresh
  2. Debug information is being dumped in console
  3. There are still some rough edges when parsing Java classes because of the way unrepl works
  4. Console does not show exceptions when an error occurs
  5. There are still some problems when parsing exceptions (Clojure sometimes misses stacktrace)
  6. There's no "goto definition", no "refactoring" yet
  7. The option to connect to a self-hosted ClojureScript socket REPL does nothing for now
  8. No support for Figwheel, Sidecar, etc (yet)
  9. We only connect on shadow-cljs if there a dev named build
  10. No way to toggle between Clojure and ClojureScript (for now, when you eval a CLJS file, it'll evaluate as ClojureScript, and every other file it'll evaluate as Clojure)
  11. There are APIs for AutoComplete with ClojureScript (emacs uses then!), but they are not yet supported (in fact, Shadow-CLJS does support then but it's still not wired correctly)
  12. There are no tests! Most of the tests are in REPL-Tooling library, but they are outdated

TODO

  • Auto-complete on Clojure with Compliment
  • Auto-complete on ClojureScript with Simple-Complete (somewhat)
  • Auto-complette on ClojureScript with cljs-tooling
  • Auto-complete on Lumo
  • Refresh with Clojure (require :reload)
  • Refresh with Clojure tools.nrepl
  • Debugger
  • Auto-import?
  • Remove unused NS
You can’t perform that action at this time.