Git Product home page Git Product logo

replique's Introduction

Replique

Replique is a development environment for Clojure and Clojurescript.

Replique relies on the Clojure command line tools for starting REPLs. The Clojure command line tools must be installed before using Replique.

If you are interested in using Replique, you should check out its emacs mode.

Overview

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

Create an empty directory named "replique-demo". In the replique-demo directory, create a file named "deps.edn" with the following content.

{:deps {replique/replique {:git/url "https://github.com/EwenG/replique.git" 
                           :git/tag "1.0.0"
                           :git/sha "039e8bc"}
        org.clojure/clojurescript {:mvn/version "1.11.60"}}}

The dependency on Clojurescript is not strictly needed but is added because we will later start a Clojurescript REPL.

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

clj -J-Dreplique.server.port=9000 -J-Dreplique.http-server.port=9001 -M -m replique.main

In an other terminal, connect to the REPL server:

telnet localhost 9000

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. Ensure that you added a Clojurescript dependency to your deps.edn 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 9001 ...

Open a browser tab at localhost:9001

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 prompt, 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 :completion 
                                          :repl-env :replique/clj
                                          :context nil
                                          :ns 'replique.repl
                                          :prefix "tooli"})

=>

{:candidates ({:candidate "tooling-msg", :type :namespace, :match-index 5} 
              {:candidate "tooling-repl", :type :function, :ns "replique.repl", :match-index 5} 
              {:candidate "replique.tooling", :type :namespace, :match-index 14} 
              {:candidate "shared-tooling-repl", :type :function, :ns "replique.repl", :match-index 12} 
              {:candidate "replique.tooling-msg", :type :namespace, :match-index 14}),
 :type :completion,
 :repl-env :replique/clj,
 :context nil,
 :ns replique.repl,
 :prefix "tooli"}

We are done, kill the process to exit.


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

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

plumpmath

replique's Issues

How to use it?

Sorry to ask such a simple thing, but if you could help me to test it I would appreciate it.

Thanks in advance

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.