From 78c15dbed631676743c052521141934073ad9080 Mon Sep 17 00:00:00 2001 From: Simon Brooke Date: Thu, 12 Sep 2019 12:33:21 +0100 Subject: [PATCH] Added an empty Clojure/ClojureScript project, about to add a Lisp one. --- README.md | 6 +++ dev/user.clj | 42 +++++++++++++++ project.clj | 98 ++++++++++++++++++++++++++++++++++ resources/public/css/style.css | 2 + resources/public/index.html | 16 ++++++ src/cljs/ledit/core.cljs | 17 ++++++ src/lisp/ledit.lisp | 0 7 files changed, 181 insertions(+) create mode 100644 dev/user.clj create mode 100644 project.clj create mode 100644 resources/public/css/style.css create mode 100644 resources/public/index.html create mode 100644 src/cljs/ledit/core.cljs create mode 100644 src/lisp/ledit.lisp diff --git a/README.md b/README.md index 5adb432..a798431 100644 --- a/README.md +++ b/README.md @@ -5,3 +5,9 @@ A working Lisp editor There is nothing here yet. You cannot use it. It is just a very rough plan. +## Clojure implementation + +There is the beginnings of a Clojure implementation. This is probably just proof-of-concept rapid prototyping. Clojure makes it extremely hard to rebind symbols, so in-core editing of Clojure is going to be pretty hard to make work. It's highly likely that working LEdit will be Common Lisp only. + + + diff --git a/dev/user.clj b/dev/user.clj new file mode 100644 index 0000000..77dcc03 --- /dev/null +++ b/dev/user.clj @@ -0,0 +1,42 @@ +(ns user + (:require + [figwheel-sidecar.repl-api :as f])) + +;; user is a namespace that the Clojure runtime looks for and +;; loads if its available + +;; You can place helper functions in here. This is great for starting +;; and stopping your webserver and other development services + +;; The definitions in here will be available if you run "lein repl" or launch a +;; Clojure repl some other way + +;; You have to ensure that the libraries you :require are listed in your dependencies + +;; Once you start down this path +;; you will probably want to look at +;; tools.namespace https://github.com/clojure/tools.namespace +;; and Component https://github.com/stuartsierra/component + + +(defn fig-start + "This starts the figwheel server and watch based auto-compiler." + [] + ;; this call will only work as long as your :cljsbuild and + ;; :figwheel configurations are at the top level of your project.clj + ;; and are not spread across different lein profiles + + ;; otherwise you can pass a configuration into start-figwheel! manually + (f/start-figwheel!)) + +(defn fig-stop + "Stop the figwheel server and watch based auto-compiler." + [] + (f/stop-figwheel!)) + +;; if you are in an nREPL environment you will need to make sure you +;; have setup piggieback for this to work +(defn cljs-repl + "Launch a ClojureScript REPL that is connected to your build and host environment." + [] + (f/cljs-repl)) diff --git a/project.clj b/project.clj new file mode 100644 index 0000000..7d6dcab --- /dev/null +++ b/project.clj @@ -0,0 +1,98 @@ +(defproject ledit "0.1.0-SNAPSHOT" + :deploy-repositories [["releases" :clojars] + ["snapshots" :clojars]] + + :description "A version of LEdit in Clojure - probably just a rapid prototype." + :url "http://example.com/FIXME" + :license {:name "GNU General Public License, version 2.0 or (at your option) any later version" + :url "https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html"} + + :min-lein-version "2.9.1" + + :dependencies [[org.clojure/clojure "1.8.0"] ;; not 1.10 because LightTable doesn't yet support it + [org.clojure/clojurescript "1.10.520"] + [org.clojure/core.async "0.4.500"]] + + :plugins [[lein-figwheel "0.5.19"] + [lein-cljsbuild "1.1.7" :exclusions [[org.clojure/clojure]]]] + + :source-paths ["src/clj"] + + :cljsbuild {:builds + [{:id "dev" + :source-paths ["src/cljs" "src/cljc" "env/dev/cljs"] + + ;; The presence of a :figwheel configuration here + ;; will cause figwheel to inject the figwheel client + ;; into your build + :figwheel {:on-jsload "ledit.core/on-js-reload" + ;; :open-urls will pop open your application + ;; in the default browser once Figwheel has + ;; started and compiled your application. + ;; Comment this out once it no longer serves you. + :open-urls ["http://localhost:3449/index.html"]} + + :compiler {:main ledit.core + :asset-path "js/compiled/out" + :output-to "resources/public/js/compiled/ledit.js" + :output-dir "resources/public/js/compiled/out" + :source-map-timestamp true + ;; To console.log CLJS data-structures make sure you enable devtools in Chrome + ;; https://github.com/binaryage/cljs-devtools + :preloads [devtools.preload]}} + ;; This next build is a compressed minified build for + ;; production. You can build this with: + ;; lein cljsbuild once min + {:id "min" + :source-paths ["src"] + :compiler {:output-to "resources/public/js/compiled/ledit.js" + :main ledit.core + :optimizations :advanced + :pretty-print false}}]} + + :figwheel {;; :http-server-root "public" ;; default and assumes "resources" + ;; :server-port 3449 ;; default + ;; :server-ip "127.0.0.1" + + :css-dirs ["resources/public/css"] ;; watch and update CSS + + ;; Start an nREPL server into the running figwheel process + ;; :nrepl-port 7888 + + ;; Server Ring Handler (optional) + ;; if you want to embed a ring handler into the figwheel http-kit + ;; server, this is for simple ring servers, if this + + ;; doesn't work for you just run your own server :) (see lein-ring) + + ;; :ring-handler hello_world.server/handler + + ;; To be able to open files in your editor from the heads up display + ;; you will need to put a script on your path. + ;; that script will have to take a file path and a line number + ;; ie. in ~/bin/myfile-opener + ;; #! /bin/sh + ;; emacsclient -n +$2 $1 + ;; + ;; :open-file-command "myfile-opener" + + ;; if you are using emacsclient you can just use + ;; :open-file-command "emacsclient" + + ;; if you want to disable the REPL + ;; :repl false + + ;; to configure a different figwheel logfile path + ;; :server-logfile "tmp/logs/figwheel-logfile.log" + + ;; to pipe all the output to the repl + ;; :server-logfile false + } + + :profiles {:dev {:dependencies [[binaryage/devtools "0.9.10"] + [figwheel-sidecar "0.5.19"]] + ;; need to add dev source path here to get user.clj loaded + :source-paths ["src" "dev"] + ;; need to add the compliled assets to the :clean-targets + :clean-targets ^{:protect false} ["resources/public/js/compiled" + :target-path]}}) diff --git a/resources/public/css/style.css b/resources/public/css/style.css new file mode 100644 index 0000000..26163d2 --- /dev/null +++ b/resources/public/css/style.css @@ -0,0 +1,2 @@ +/* some style */ + diff --git a/resources/public/index.html b/resources/public/index.html new file mode 100644 index 0000000..736b2a1 --- /dev/null +++ b/resources/public/index.html @@ -0,0 +1,16 @@ + + + + + + + + + +
+

Figwheel template

+

Checkout your developer console.

+
+ + + diff --git a/src/cljs/ledit/core.cljs b/src/cljs/ledit/core.cljs new file mode 100644 index 0000000..d37d22d --- /dev/null +++ b/src/cljs/ledit/core.cljs @@ -0,0 +1,17 @@ +(ns ledit.core + (:require )) + +(enable-console-print!) + +(println "This text is printed from src/ledit/core.cljs. Go ahead and edit it and see reloading in action.") + +;; define your app data so that it doesn't get over-written on reload + +(defonce app-state (atom {:text "Hello world!"})) + + +(defn on-js-reload [] + ;; optionally touch your app-state to force rerendering depending on + ;; your application + ;; (swap! app-state update-in [:__figwheel_counter] inc) +) diff --git a/src/lisp/ledit.lisp b/src/lisp/ledit.lisp new file mode 100644 index 0000000..e69de29