Skip to content
This repository was archived by the owner on Oct 21, 2022. It is now read-only.

Commit 21c230d

Browse files
committed
Merge pull request #29 from LightTable/one-keystroke-cljs-eval
One keystroke cljs eval
2 parents 9834dbe + 6bdafe9 commit 21c230d

5 files changed

Lines changed: 787 additions & 622 deletions

File tree

README.md

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,30 +10,38 @@ This plugin requires projects Clojure 1.5.1 and higher. Starting with 0.2.0 this
1010

1111
This plugin works for projects on recent versions of ClojureScript e.g. 1.7.X. For projects with ClojureScript versions 0.0-2341 and higher, Clojure 1.7.0 is required.
1212

13-
## First ClojureScript Repl
14-
15-
Welcome first time ClojureScript users! Please see [David Nolen's tutorial](https://github.com/swannodette/lt-cljs-tutorial) to get familiar with ClojureScript and comfortable with LightTable's repl. Note while doing that tutorial you were in a namespace. A namespace is necessary for a LightTable repl. Once you have finished the tutorial, create your own ClojureScript project with `lein new mies my-project` and eval there. If you want to add dependencies to your project, read the [below section](#clojurescript-eval) as that requires a different type of LightTable connection.
16-
1713
## Cljc eval
1814

1915
By default, \*.cljc files are identified as Clojure files. Thus when you eval, it will eval as a
2016
Clojure file. If you'd like to eval as a ClojureScript file, run the command `Editor: Set current
2117
editor syntax`, select `ClojureScript` and then eval.
2218

19+
## First ClojureScript Repl
20+
21+
Welcome first time ClojureScript users! Please see [David Nolen's tutorial](https://github.com/swannodette/lt-cljs-tutorial) to get familiar with ClojureScript and comfortable with LightTable's repl. Note while doing that tutorial you were in a namespace. A namespace is necessary for a LightTable repl. Once you have finished the tutorial, create your own ClojureScript project with `lein new mies my-project` and eval there. If you want to add dependencies to your project, read the [below section](#clojurescript-eval) as that requires a different type of LightTable connection.
22+
2323
## ClojureScript Eval
2424

25-
There are 3 options to eval ClojureScript, 2 of which use your ClojureScript javascript. To add one of these connections, run the command `Connect: Add Connection`. The 3 connections to choose from:
25+
There are 4 options to eval ClojureScript, 3 of which use your ClojureScript javascript. To add one of these connections, run the command `Connect: Add Connection`. The 3 connections to choose from:
2626

2727
1. `Light Table UI` - Connect to the LightTable js process. Great for a headless mode, writing plugins and to try out ClojureScript features. Note, you use the ClojureScript version that comes with LightTable.
2828

29-
2. `Browser` - Connect to a web page that has the compiled ClojureScript sourced e.g. `file:///path/to/index.html`. You must navigate the internal browser to that web page. Recommended for ease of use.
29+
2. `ClojureScript Browser` - Connect to a web page that has the compiled ClojureScript sourced e.g. `file:///path/to/index.html`. The internal browser is automatically opened to a web page based on configurable paths from behavior `:lt.plugins.clojure/set-cljs-browser-paths`. Recommended for ease of use.
3030

31-
3. `Browser (External)` - Connect to a web page that has the compiled ClojureScript sourced e.g. `file:///path/to/index.html`. In addition to navigating the external browser, you must copy the script tag into that web page. Requires more setup than the internal browser but gives you the freedom to use any browser.
31+
3. `Browser` - Connect to a web page that has the compiled ClojureScript sourced e.g. `file:///path/to/index.html`. You must navigate the internal browser to that web page.
32+
33+
4. `Browser (External)` - Connect to a web page that has the compiled ClojureScript sourced e.g. `file:///path/to/index.html`. In addition to navigating the external browser, you must copy the script tag into that web page. Requires more setup than the internal browser but gives you the freedom to use any browser.
3234

3335
Note that for Browser options, compiled ClojureScript cannot be compiled with `:advanced` `:optimizations` mode.
3436

3537
## ClojureScript Workflows
3638

39+
Starting with 0.2.0, when you eval a cljs file, LT automatically chooses an appropriate cljs client for you based on the behavior `:lt.plugins.clojure/set-default-cljs-client`.
40+
For ClojureScript projects, the `ClojureScript Browser` client opens an internal browser and attempts to find a valid url to connect to using possible paths from behavior `:lt.plugins.clojure/set-cljs-browser-paths`.
41+
This means that before your first eval, your cljs assets _must_ already be compiled e.g. `lein cljsbuild once`. Make sure the namespace you're evaling is included in your compiled assets. For
42+
example, if you're in a test namespace, your client browser _must_ be connected to an html file that includes test namespaces. In other words a test build of compiled assets must exist e.g. `lein cljsbuild once test` and an associated html file that sources in that compiled js.
43+
For LightTable plugins, the `Light Table UI` client is started and eval should just work.
44+
3745
For ClojureScript projects:
3846

3947
Your project is connected to a browser. Recompile cljs outside of LT with project's cljs compile tool e.g. `lein cljsbuild auto`.

clojure.behaviors

Lines changed: 130 additions & 128 deletions
Original file line numberDiff line numberDiff line change
@@ -1,128 +1,130 @@
1-
{:+
2-
{:app [(:lt.objs.plugins/load-js ["codemirror/clojure-mode.js" "clojure_compiled.js"])]
3-
4-
:files [(:lt.objs.files/file-types [{:name "Clojure" :exts [:clj] :mime "text/x-clojure" :tags [:editor.clj :editor.clojure]}
5-
{:name "ClojureScript" :exts [:cljs] :mime "text/x-clojurescript" :tags [:editor.cljs :editor.clojurescript]}
6-
{:name "Clojure/ClojureScript" :exts [:cljc], :mime "text/x-clojure", :tags [:editor.clj :editor.clojure]}])]
7-
8-
:clojure.lang [:lt.plugins.clojure/connect-local
9-
:lt.plugins.clojure/eval!
10-
:lt.plugins.clojure/build!]
11-
12-
:clients [:lt.plugins.clojure/handle-cancellation]
13-
14-
:plugin.file [:lt.plugins.clojure/build-cljs-plugin
15-
:lt.plugins.clojure/plugin-compile-results]
16-
17-
:sidebar.docs.search [:lt.plugins.clojure/clj-doc-search
18-
:lt.plugins.clojure/cljs-doc-search]
19-
20-
:nrepl.client.common [:lt.plugins.clojure.nrepl/nrepl-message
21-
:lt.plugins.clojure.nrepl/nrepl-connect
22-
:lt.plugins.clojure.nrepl/nrepl-send!
23-
:lt.plugins.clojure.nrepl/connect!
24-
:lt.plugins.clojure.nrepl/try-connect!
25-
:lt.plugins.clojure.nrepl/close
26-
:lt.plugins.clojure/eval-print-err
27-
:lt.plugins.clojure/eval-print
28-
:lt.plugins.clojure/clj-result
29-
:lt.plugins.clojure/clj-exception]
30-
31-
:nrepl.client [:lt.plugins.clojure.nrepl/client.settings
32-
:lt.plugins.clojure.nrepl/init-session
33-
(:lt.object/add-tag :nrepl.client.common)]
34-
35-
:nrepl.client.remote [:lt.plugins.clojure.nrepl/client.settings.remote
36-
:lt.plugins.clojure.nrepl/init-remote-session
37-
(:lt.object/add-tag :nrepl.client.common)]
38-
39-
:editor.clj.jump-to-definition [:lt.plugins.clojure/jump-to-definition-at-cursor
40-
:lt.plugins.clojure/start-jump-to-definition
41-
:lt.plugins.clojure/finish-jump-to-definition]
42-
43-
:editor.clj.hints [:lt.plugins.clojure/clj-result ;; to get hints
44-
:lt.plugins.clojure/trigger-update-hints
45-
:lt.plugins.clojure/finish-update-hints
46-
:lt.plugins.clojure/use-local-hints
47-
]
48-
49-
:editor.clj.common [:lt.plugins.clojure/on-result-set-ns
50-
:lt.plugins.clojure/no-op
51-
[:lt.object/add-tag :watchable]
52-
[:lt.object/add-tag :docable]
53-
(:lt.object/add-tag :editor.clj.hints)
54-
(:lt.object/add-tag :editor.clj.jump-to-definition)
55-
:lt.plugins.clojure/on-eval.custom]
56-
57-
:editor.clj.eval [:lt.plugins.clojure/on-eval.one
58-
:lt.plugins.clojure/on-eval.clj
59-
:lt.plugins.clojure/eval-location]
60-
61-
:editor.cljs.eval [:lt.plugins.clojure/on-eval.one
62-
:lt.plugins.clojure/on-eval.cljs
63-
:lt.plugins.clojure/eval-location]
64-
65-
:editor.clj [(:lt.object/add-tag :editor.clj.common)
66-
(:lt.object/add-tag :editor.clj.eval)
67-
:lt.plugins.clojure/eval-print
68-
:lt.plugins.clojure/eval-print-err
69-
:lt.plugins.clojure/clj-result
70-
:lt.plugins.clojure/clj-result.inline
71-
:lt.plugins.clojure/clj-result.statusbar
72-
:lt.plugins.clojure/clj-result.replace
73-
:lt.plugins.clojure/clj-result.inline-at-cursor
74-
:lt.plugins.clojure/clj-result.return
75-
:lt.plugins.clojure/clj-exception
76-
:lt.plugins.clojure/clj-watch-result
77-
:lt.plugins.clojure/clj-watch-src
78-
:lt.plugins.clojure/clj-watch-custom-src
79-
:lt.plugins.clojure/clj-doc
80-
:lt.plugins.clojure/print-clj-doc]
81-
82-
:editor.cljs [(:lt.object/add-tag :editor.clj.common)
83-
(:lt.object/add-tag :editor.cljs.eval)
84-
:lt.plugins.clojure/eval-print
85-
:lt.plugins.clojure/eval-print-err
86-
:lt.plugins.clojure/exec.cljs!
87-
:lt.plugins.clojure/on-code
88-
:lt.plugins.clojure/cljs-result
89-
:lt.plugins.clojure/cljs-result.inline
90-
:lt.plugins.clojure/cljs-result.statusbar
91-
:lt.plugins.clojure/cljs-result.replace
92-
:lt.plugins.clojure/cljs-result.inline-at-cursor
93-
:lt.plugins.clojure/cljs-result.return
94-
:lt.plugins.clojure/cljs-exception
95-
:lt.plugins.clojure/cljs-watch-result
96-
:lt.plugins.clojure/cljs-watch-src
97-
:lt.plugins.clojure/cljs-watch-custom-src
98-
:lt.plugins.clojure/cljs-doc
99-
:lt.plugins.clojure/print-cljs-doc
100-
:lt.objs.plugins/check-for-plugin-file]
101-
102-
:editor.clj.instarepl [(:lt.object/add-tag :editor.clj.common)
103-
:lt.plugins.clojure.instarepl/on-eval-one
104-
:lt.plugins.clojure.instarepl/set-parent-title
105-
:lt.plugins.clojure.instarepl/on-eval-sonar
106-
:lt.plugins.clojure.instarepl/dirty-parent
107-
:lt.plugins.clojure.instarepl/eval-on-change
108-
:lt.plugins.clojure.instarepl/close-parent
109-
:lt.plugins.clojure/clj-result.inline
110-
:lt.plugins.clojure/clj-result.statusbar
111-
:lt.plugins.clojure/clj-result.replace
112-
:lt.plugins.clojure/clj-watch-result
113-
:lt.plugins.clojure/clj-watch-src
114-
:lt.plugins.clojure/clj-watch-custom-src
115-
:lt.plugins.clojure/clj-doc
116-
:lt.plugins.clojure/print-clj-doc]
117-
118-
:instarepl [:lt.plugins.clojure.instarepl/sonar-result
119-
:lt.plugins.clojure.instarepl/clj-exception
120-
:lt.plugins.clojure.instarepl/on-show-refresh-eds
121-
:lt.plugins.clojure.instarepl/destroy-on-close
122-
:lt.plugins.clojure.instarepl/reroute-watches
123-
:lt.plugins.clojure.instarepl/live-toggle
124-
:lt.plugins.clojure.instarepl/on-focus-focus-ed
125-
:lt.plugins.clojure.instarepl/no-op
126-
:lt.plugins.clojure.instarepl/cleanup-on-destroy
127-
:lt.plugins.clojure/eval-print-err
128-
:lt.plugins.clojure/eval-print]}}
1+
[
2+
[:app :lt.objs.plugins/load-js ["codemirror/clojure-mode.js" "clojure_compiled.js"]]
3+
[:app :lt.plugins.clojure/set-default-cljs-client :auto]
4+
[:app :lt.plugins.clojure/set-cljs-browser-paths ["index.html" "resources/public/index.html" "public/index.html" "dev-resources/public/index.html"]]
5+
6+
[:clients :lt.plugins.clojure/handle-cancellation]
7+
8+
[:clojure.lang :lt.plugins.clojure/connect-local]
9+
[:clojure.lang :lt.plugins.clojure/eval!]
10+
[:clojure.lang :lt.plugins.clojure/build!]
11+
12+
[:editor.clj :lt.object/add-tag :editor.clj.common]
13+
[:editor.clj :lt.object/add-tag :editor.clj.eval]
14+
[:editor.clj :lt.plugins.clojure/eval-print]
15+
[:editor.clj :lt.plugins.clojure/eval-print-err]
16+
[:editor.clj :lt.plugins.clojure/clj-result]
17+
[:editor.clj :lt.plugins.clojure/clj-result.inline]
18+
[:editor.clj :lt.plugins.clojure/clj-result.statusbar]
19+
[:editor.clj :lt.plugins.clojure/clj-result.replace]
20+
[:editor.clj :lt.plugins.clojure/clj-result.inline-at-cursor]
21+
[:editor.clj :lt.plugins.clojure/clj-result.return]
22+
[:editor.clj :lt.plugins.clojure/clj-exception]
23+
[:editor.clj :lt.plugins.clojure/clj-watch-result]
24+
[:editor.clj :lt.plugins.clojure/clj-watch-src]
25+
[:editor.clj :lt.plugins.clojure/clj-watch-custom-src]
26+
[:editor.clj :lt.plugins.clojure/clj-doc]
27+
[:editor.clj :lt.plugins.clojure/print-clj-doc]
28+
29+
[:editor.clj.common :lt.plugins.clojure/on-result-set-ns]
30+
[:editor.clj.common :lt.plugins.clojure/no-op]
31+
[:editor.clj.common :lt.object/add-tag :watchable]
32+
[:editor.clj.common :lt.object/add-tag :docable]
33+
[:editor.clj.common :lt.object/add-tag :editor.clj.hints]
34+
[:editor.clj.common :lt.object/add-tag :editor.clj.jump-to-definition]
35+
[:editor.clj.common :lt.plugins.clojure/on-eval.custom]
36+
37+
[:editor.clj.eval :lt.plugins.clojure/on-eval.one]
38+
[:editor.clj.eval :lt.plugins.clojure/on-eval.clj]
39+
[:editor.clj.eval :lt.plugins.clojure/eval-location]
40+
41+
[:editor.clj.hints :lt.plugins.clojure/clj-result]
42+
[:editor.clj.hints :lt.plugins.clojure/trigger-update-hints]
43+
[:editor.clj.hints :lt.plugins.clojure/finish-update-hints]
44+
[:editor.clj.hints :lt.plugins.clojure/use-local-hints]
45+
46+
[:editor.clj.instarepl :lt.object/add-tag :editor.clj.common]
47+
[:editor.clj.instarepl :lt.plugins.clojure.instarepl/on-eval-one]
48+
[:editor.clj.instarepl :lt.plugins.clojure.instarepl/set-parent-title]
49+
[:editor.clj.instarepl :lt.plugins.clojure.instarepl/on-eval-sonar]
50+
[:editor.clj.instarepl :lt.plugins.clojure.instarepl/dirty-parent]
51+
[:editor.clj.instarepl :lt.plugins.clojure.instarepl/eval-on-change]
52+
[:editor.clj.instarepl :lt.plugins.clojure.instarepl/close-parent]
53+
[:editor.clj.instarepl :lt.plugins.clojure/clj-result.inline]
54+
[:editor.clj.instarepl :lt.plugins.clojure/clj-result.statusbar]
55+
[:editor.clj.instarepl :lt.plugins.clojure/clj-result.replace]
56+
[:editor.clj.instarepl :lt.plugins.clojure/clj-watch-result]
57+
[:editor.clj.instarepl :lt.plugins.clojure/clj-watch-src]
58+
[:editor.clj.instarepl :lt.plugins.clojure/clj-watch-custom-src]
59+
[:editor.clj.instarepl :lt.plugins.clojure/clj-doc]
60+
[:editor.clj.instarepl :lt.plugins.clojure/print-clj-doc]
61+
62+
[:editor.clj.jump-to-definition :lt.plugins.clojure/jump-to-definition-at-cursor]
63+
[:editor.clj.jump-to-definition :lt.plugins.clojure/start-jump-to-definition]
64+
[:editor.clj.jump-to-definition :lt.plugins.clojure/finish-jump-to-definition]
65+
66+
[:editor.cljs :lt.object/add-tag :editor.clj.common]
67+
[:editor.cljs :lt.object/add-tag :editor.cljs.eval]
68+
[:editor.cljs :lt.plugins.clojure/eval-print]
69+
[:editor.cljs :lt.plugins.clojure/eval-print-err]
70+
[:editor.cljs :lt.plugins.clojure/exec.cljs!]
71+
[:editor.cljs :lt.plugins.clojure/on-code]
72+
[:editor.cljs :lt.plugins.clojure/cljs-result]
73+
[:editor.cljs :lt.plugins.clojure/cljs-result.inline]
74+
[:editor.cljs :lt.plugins.clojure/cljs-result.statusbar]
75+
[:editor.cljs :lt.plugins.clojure/cljs-result.replace]
76+
[:editor.cljs :lt.plugins.clojure/cljs-result.inline-at-cursor]
77+
[:editor.cljs :lt.plugins.clojure/cljs-result.return]
78+
[:editor.cljs :lt.plugins.clojure/cljs-exception]
79+
[:editor.cljs :lt.plugins.clojure/cljs-watch-result]
80+
[:editor.cljs :lt.plugins.clojure/cljs-watch-src]
81+
[:editor.cljs :lt.plugins.clojure/cljs-watch-custom-src]
82+
[:editor.cljs :lt.plugins.clojure/cljs-doc]
83+
[:editor.cljs :lt.plugins.clojure/print-cljs-doc]
84+
[:editor.cljs :lt.objs.plugins/check-for-plugin-file]
85+
86+
[:editor.cljs.eval :lt.plugins.clojure/on-eval.one]
87+
[:editor.cljs.eval :lt.plugins.clojure/on-eval.cljs]
88+
[:editor.cljs.eval :lt.plugins.clojure/eval-location]
89+
90+
[:files :lt.objs.files/file-types [{:exts [:clj], :mime "text/x-clojure", :tags [:editor.clj :editor.clojure], :name "Clojure"}
91+
{:exts [:cljs], :mime "text/x-clojurescript", :tags [:editor.cljs :editor.clojurescript], :name "ClojureScript"}
92+
{:exts [:cljc], :mime "text/x-clojure", :tags [:editor.clj :editor.clojure], :name "Clojure/ClojureScript"}]]
93+
94+
[:instarepl :lt.plugins.clojure.instarepl/sonar-result]
95+
[:instarepl :lt.plugins.clojure.instarepl/clj-exception]
96+
[:instarepl :lt.plugins.clojure.instarepl/on-show-refresh-eds]
97+
[:instarepl :lt.plugins.clojure.instarepl/destroy-on-close]
98+
[:instarepl :lt.plugins.clojure.instarepl/reroute-watches]
99+
[:instarepl :lt.plugins.clojure.instarepl/live-toggle]
100+
[:instarepl :lt.plugins.clojure.instarepl/on-focus-focus-ed]
101+
[:instarepl :lt.plugins.clojure.instarepl/no-op]
102+
[:instarepl :lt.plugins.clojure.instarepl/cleanup-on-destroy]
103+
[:instarepl :lt.plugins.clojure/eval-print-err]
104+
[:instarepl :lt.plugins.clojure/eval-print]
105+
106+
[:nrepl.client :lt.plugins.clojure.nrepl/client.settings]
107+
[:nrepl.client :lt.plugins.clojure.nrepl/init-session]
108+
[:nrepl.client :lt.object/add-tag :nrepl.client.common]
109+
110+
[:nrepl.client.common :lt.plugins.clojure.nrepl/nrepl-message]
111+
[:nrepl.client.common :lt.plugins.clojure.nrepl/nrepl-connect]
112+
[:nrepl.client.common :lt.plugins.clojure.nrepl/nrepl-send!]
113+
[:nrepl.client.common :lt.plugins.clojure.nrepl/connect!]
114+
[:nrepl.client.common :lt.plugins.clojure.nrepl/try-connect!]
115+
[:nrepl.client.common :lt.plugins.clojure.nrepl/close]
116+
[:nrepl.client.common :lt.plugins.clojure/eval-print-err]
117+
[:nrepl.client.common :lt.plugins.clojure/eval-print]
118+
[:nrepl.client.common :lt.plugins.clojure/clj-result]
119+
[:nrepl.client.common :lt.plugins.clojure/clj-exception]
120+
121+
[:nrepl.client.remote :lt.plugins.clojure.nrepl/client.settings.remote]
122+
[:nrepl.client.remote :lt.plugins.clojure.nrepl/init-remote-session]
123+
[:nrepl.client.remote :lt.object/add-tag :nrepl.client.common]
124+
125+
[:plugin.file :lt.plugins.clojure/build-cljs-plugin]
126+
[:plugin.file :lt.plugins.clojure/plugin-compile-results]
127+
128+
[:sidebar.docs.search :lt.plugins.clojure/clj-doc-search]
129+
[:sidebar.docs.search :lt.plugins.clojure/cljs-doc-search]
130+
]

0 commit comments

Comments
 (0)