Git Product home page Git Product logo

replique's Introduction

Replique

Replique is a development environment for Clojure and Clojurescript implemented as a Leiningen plugin. The easiest way to start with Replique is to use a client. The only client currently available is an emacs mode. If you are interested in writing a client for another text editor/ide, please fill an issue to ask for more documentation :)

Overview

The following is an overview of Replique features, demonstrating the use of Replique with only the help of a terminal.

Create an empty leiningen project. Add Replique to your plugins and Clojurescript to your depenencies. Clojurescript is necessary because we will later start a Clojurescript REPL.

(defproject replique-demo "0.0.1"
  :dependencies [[org.clojure/clojurescript "x.x.x"]]
  :plugins [[replique/replique "0.0.3"]])

From the project directory, start a REPL server on port 9000:

lein replique localhost 9000

In an other terminal, connect to the REPL server:

telnet localhost 9000

Enter the 'R' character. You must enter this first character before anything else. The reason is that the REPL server is able to understand several protocols and, in order to recognise the right protocol, the server checks the first character sent by the client.

You are now in a Clojure REPL. You will notice that the current REPL does not print a prompt. The reason is Replique is designed to be easy to integrate into a text editor or an IDE. By not printing the prompt we make the REPL output easier to parse for the machine. You can enter any Clojure expression to get it evaluated.

(+ 1 2) => 3

Now let's start a more familiar Clojure REPL:

(replique.repl/repl)

A prompt is now printed. Again, you can enter any Clojure expression.

Let's start a Clojurescipt REPL. Be sure you added a Clojurescript dependency to your project.clj file, as described earlier.

(replique.interactive/cljs-repl)

Wait a few seconds for the Clojurescript core libraries to be compiled. Javascript files get compiled to the target/cljs folder. As you can now see, the Clojurescript REPL is waiting for a browser to connect on port 9000 ...

Waiting for browser to connect on port 9000 ...

Open a browser tab at localhost:9000

You are now able to evaluate Clojurescript expressions at the REPL:

(js/alert "Hello from Replique")

You can also load entire files. Create a file named test.cljs at the root of the current directory. Add the following content to the new file:

(ns test)
(js/alert "This file has been compiled to disk and loaded in the browser")

Load the file in the browser:

(replique.interactive/load-file "test.cljs")

The file has been loaded in the browser AND compiled to disk. It can be linked in HTML markup to be automatically loaded after a browser refresh.

Quit the Clojurescript REPL to come back to the Clojure REPL:

:cljs/quit

Replique can be used to enhance your REPL with tooling features. Tooling features are optional. The code supporting them has not been loaded into the Clojure process yet. To leverage tooling features, it is best to use an editor or IDE.

Let's start a "tooling" REPL.

(replique.repl/shared-tooling-repl :edn)

Notice that no prompt is printed. By not pinting a rompt, we make the REPL output easier to parse by the machine. The first parameter, :edn, instructs the REPL to print the tooling messages using the EDN format. The tooling REPL currently supports two formats: EDN and elisp.

Enter the following in the tooling REPL:

(replique.tooling-msg/tooling-msg-handle {:type :clj-completion
                                          :context nil
                                          :ns 'replique.repl
                                          :prefix "tooli"})

=>

{:type :clj-completion
 :process-id #uuid "5e1ffe41-797a-4379-a52a-e1d82d1704cd"
 :candidates ({:candidate "tooling-msg" :type :namespace}
              {:candidate "tooling-repl" :type :function :ns "replique.repl"})}

We are done, kill the process to exit.


Acknowledgments

Several features of Replique were built using compliment. I would like to thank the compliment authors/contributors.

License

Copyright 2016 Ewen Grosjean.

The use and distribution terms for this software are covered by the Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0) which can be found in the file epl-v10.html at the root of this distribution.

By using this software in any fashion, you are agreeing to be bound by the terms of this license.

You must not remove this notice, or any other, from this software.

replique's People

Contributors

eweng avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.