• Stars
    star
    175
  • Rank 211,191 (Top 5 %)
  • Language
    Clojure
  • License
    MIT License
  • Created over 5 years ago
  • Updated about 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

An Atom plugin to integrate with Socket-REPL over Clojure, ClojureScript, ClojureCLR, Joker, Babashka, Clojerl, Lumo and Plank

Chlorine

CircleCI

Cl + Atom = Chlorine

Socket-REPL integration with Clojure and ClojureScript with Atom.

This project also have a FAQ now

WARNING

This project is migrated to GitLab. This repository just exists because it needs to be on GitHub for publication to work. Updated documentation, etc, must be sent to GitLab only.

Example

Chlorine connects to a Socket REPL and adds autocomplete, goto var definition, evaluation, refresh, and documentation of functions on Atom. It can also add additional things, so check it out on extending Chlorine. The idea of the project is to give Atom a felling of being completely connected to running code that's being developed, like SmallTalk images but still working with textual source codes, git, and every other tool that we already use with our code.

Evaluating code

As it is possible to see above, Chlorine works both with Clojure and ClojureScript (only shadow-cljs for now).

Usage:

If you are new to Clojure or Atom, you may check this quickstart guide.

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 (on Linux or MacOS):

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

On Windows, you can add a profile on project.clj that will add these JVM options; to do it, check if your project.clj have the :profiles key. If it does, just add the :socket part, if it does not, add the :profiles tag and then the :socket:

  ; ... dependencies, main, etc ...
  :profiles {:socket {:jvm-opts ["-Dclojure.server.myrepl={:port,5555,:accept,clojure.core.server/repl}"]}}

Then, you can run lein with-profile +socket repl, and it'll open a Socket REPL on port 5555.

On Shadow-CLJS' newer versions, when you start a build with shadow-cljs watch <some-id>, it doesn't shows the Socket REPL port on the console, but it does create a file with the port number on .shadow-cljs/socket-repl.port. You can read that file to see the port number (Chlorine currently uses this file to mark the port as default).

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 keybindings to avoid keybinding conflict issues. You can define whatever you want via keymap.cson. The following have worked for some people:

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-socket-repl'
  'space l':      'chlorine:clear-console'
  'shift-enter':  'chlorine:evaluate-block'
  'ctrl-enter':   'chlorine:evaluate-top-block'
  'ctrl-c':       'chlorine:break-evaluation'
  'space space':  'chlorine:clear-inline-results'
  '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-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:break-evaluation'
  'ctrl-; S':       '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 ClojureScript implementations like Lumo or Plank that exposes a ClojureScript socket REPL.

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 need to run the compiled javascript file in the output directory (configured in shadow-cljs.edn) - either with node <...> (if it's a node script) or by opening the browser in a page that includes the script (if you're targetting browser), connect with "Connect Socket REPL" (Chlorine will auto-detect the port - you don't need to change it), and run the command "Connect Embedded". Then you can run code on .cljs files too. For ClojureScript its also recommended to enable "experimental features" (on Chlorine settings) for better experience.

WARNING

Do not evaluate the ns form in Shadow-CLJS. Shadow keeps your namespaces reloaded all the time, and sometimes re-evaluating then can lead to strange issues. If you do evaluate the ns form and get errors, just save the current file and Shadow will hot-reload it, and things will be fine. For more info, see: #213

Detection

Chlorine will try to detect the current file extension, falling back to .clj if the file is not saved. With ClojureScript, it'll only evaluate .cljs files, and it'll use the Clojure REPL to evaluate .clj and .cljc files. You can override this behavior in the package's configuration to one of the following:

  • Prefer CLJ - The default configuration, will use the Clojure REPL to evaluate .clj and .cljc and it'll use the ClojureScript REPL to evaluate .cljs
  • Prefer CLJS - It will use the Clojure REPL to evaluate .clj and the ClojureScript REPL to evaluate .cljc and .cljs
  • CLJ - It'll use the Clojure REPL to evaluate all files
  • CLJS - It'll use the ClojureScripte REPL to evaluate all files

Contributors

How to contribute?

As Chlorine is in active development, it was starting to become tedious to publish a newer version of repl-tooling for every experiment, so for now, the library is registered as a submodule. To contribute, you clone this repository and run:

./scripts/setup

To register the submodule. More info on Developing document.

Code Contributors

This project exists thanks to all the people who contribute. [Contribute].

Financial Contributors

Become a financial contributor and help us sustain our community. Contribute:

OpenCollective:

Patreon: become a patron

Or via PayPal

Individuals

Organizations

Support this project with your organization. Your logo will show up here with a link to your website. [Contribute]

More Repositories

1

spock

Wrappers of SWI and TuProlog in Clojure
Clojure
46
star
2

clover

Visual Studio code implementation of REPL-Tooling
Clojure
44
star
3

repl-tooling

Clojure
36
star
4

lt_parinfer

Parinfer port for LightTable IDE
Clojure
17
star
5

bee-record

Where "ActiveRecord" encounters "HoneySQL"
Clojure
16
star
6

clematis

CLVIM: Clematis virginiana (devil's darning needles)
Clojure
13
star
7

duck-repled

A library to transform your REPL interation into Pathom queries
Clojure
13
star
8

check

Clojure
11
star
9

generic-lsp

Clojure
11
star
10

jasper_on_rails

Sistema de relat贸rios - integra莽茫o do Jasper com Rails
Ruby
10
star
11

clojure-plus

Additional Clojure behavior for Atom
CoffeeScript
8
star
12

arel_operators

Operators |, and, - for AREL.
Ruby
7
star
13

simple-git

Simple git plugin for ATOM
CoffeeScript
7
star
14

clojuby

Ruby on Clojure
Clojure
7
star
15

paprika

Deliciously spice utility functions for Clojure
Clojure
6
star
16

learning

Um pseudo-reposit贸rio para aprender novas linguagens usando c贸digos muito semelhantes entre todas elas
HTML
5
star
17

pathom-smart-maps

SmartMaps implementation for Pathom2
Clojure
5
star
18

fullstack-template

A Clojure template to develop fullstack apps with Pedestal and Reagent
Clojure
5
star
19

receitas

Receitas que eu costumo fazer.
3
star
20

gml2svg

Conversor de formatos de grafos GML para SVG
Ruby
3
star
21

clj-lib-deployer

A simple "Clojure library deployer" written in Babashka
BitBake
3
star
22

vim-plugins

Plugins do VIM que eu uso.
Vim Script
3
star
23

castra-users-example

Clojure
3
star
24

chess-spock-example

Clojure
2
star
25

Ruby2Scala

A wrapper to run JRuby applications in Scala
Scala
2
star
26

Things-you-never-wanted-to-know

Things you never wanted to know how to do in Ruby, and was afraid to ask.
Ruby
2
star
27

clojure-tooling-libraries

A public listing of libraries and plug-ins that provides autocomplete, refactor, etc.
2
star
28

ship_arena

Asteroids-like clone, for programming arena
Ruby
2
star
29

atom-parinfer-plus

Atom's Parinfer-Plus plugin
JavaScript
2
star
30

relational-scala

Scala's ORM. Tries to fit nicely into the language, but not aims for type-safety.
Scala
2
star
31

atom-everything

CoffeeScript
2
star
32

datomicish

A postgresql experiment with datom-like structures
Clojure
2
star
33

AgileBrazil2011

C贸digos que irei apresentar em minha palestra
Ruby
2
star
34

EnvJohnson

Test library using Env-JS 1.3-RC
JavaScript
2
star
35

Mongo-GUI

Interface gr谩fica (e um console) para MongoDB
Ruby
2
star
36

atom-rails-i18n

CoffeeScript
1
star
37

xslx-db

Clojure
1
star
38

random_stuff

Coisas Rand么micas
Ruby
1
star
39

Maemo

Programs for Maemo Linux (nokia n800, n810, n900, etc)
Ruby
1
star
40

mailchess

A really, REALLY old implementation of chess by mail, in Ruby
Ruby
1
star
41

TODO-List

Ruby
1
star
42

ruby_refactory

A new try at refactoring Ruby code.
Ruby
1
star
43

cljs-skeleton

Clojure
1
star
44

clj-js

Clojure written in mini-clojure written in Javascript
JavaScript
1
star
45

zero_rspec_matchers

New RSpec Matchers for Rails and Other Applications.
Ruby
1
star
46

relational-ruby

Ruby
1
star
47

MER-Parser

Parser para um format entidade-relacionamento bem simples.
Ruby
1
star