Skip to content

Commit 9e1037a

Browse files
committed
3.0.0 Update README.md
1 parent b283072 commit 9e1037a

File tree

5 files changed

+75
-41
lines changed

5 files changed

+75
-41
lines changed

3.0.0.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Clojure Sublimed just updated to 3.0.0! It’s a huge rewrite with many exciting features:
2+
3+
- REPL doesn’t depend on syntax highlighting anymore.
4+
- On top of JVM nREPL and ShadowCLJS nREPL, we now support Raw nREPL (no extra middlewares, so less quality, but should work anywhere) and JVM Socket REPL (works on core Clojure with 0 dependencies).
5+
- It is now much easier to add new REPLs. Contributions welcome :)
6+
- Pretty-printer now works client-side, same on every REPL.
7+
- Indenter and formatter work much faster now and do not require setting `Clojure (Sublimed)` syntax.
8+
9+
Let me know if anything breaks. If you were using JVM nREPL, I recommend switching to Socket REPL as it has better support in Clojure Sublimed, faster startup and brighter future.
10+
11+
Happy Clojure-ing!
12+
13+
Best,
14+
Nikita.

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
### WIP
1+
### 3.0.0 - Mar 9, 2023
22

33
- Huge refactoring, easier to add new REPLs
44
- REPLs do not depend on syntax highlighting anymore, will work with any syntax

README.md

Lines changed: 55 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,12 @@
55
This package provides Clojure support for Sublime Text and includes:
66

77
- Clojure and EDN syntax grammars (Sublime Text 3+)
8-
- Clojure code formatter/indenter (Sublime Text 4075+)
9-
- Clojure nREPL client (Sublime Text 4075+, nREPL 0.9+)
8+
- Code formatter/indenter (Sublime Text 4075+)
9+
- nREPL, Socket REPL, ShadowCLJS REPL clients (Sublime Text 4075+)
10+
11+
## Installation
12+
13+
`Package Control: Install Package``Clojure Sublimed`
1014

1115
## Clojure syntax
1216

@@ -22,19 +26,22 @@ Clojure Sublimed ships with its own syntax definition for Clojure and EDN. Unlik
2226
- semantically correct tokenization, perfect for fonts with ligatures,
2327
- has separate EDN syntax, same way JSON is separate from JavaScript in Sublime Text.
2428

25-
Want to put your parser to test? Check out [syntax_test_edn.edn](./test_syntax/syntax_test_edn.edn) and [syntax_test_clojure.cljc](./test_syntax/syntax_test_clojure.cljc).
29+
How to enable? Assign syntax to Clojure files:
2630

27-
Clojure Sublimed syntax is also used by nREPL client to find form boundaries and namespaces (might be changed in the future).
31+
- open any clj/cljc/cljs file,
32+
- run `View``Syntax``Open all with current extension as...``Clojure Sublimed``Clojure (Sublimed)`.
33+
34+
Want to put your parser to test? Check out [syntax_test_edn.edn](./test_syntax/syntax_test_edn.edn) and [syntax_test_clojure.cljc](./test_syntax/syntax_test_clojure.cljc).
2835

2936
## Formatter/indenter
3037

31-
Clojure Sublimed includes optional support for [Simple Clojure Formatting rules](https://tonsky.me/blog/clojurefmt/). It doesn’t require nREPL connection but does require `Clojure (Sublimed)` syntax to be selected for buffer.
38+
Clojure Sublimed includes optional support for [Simple Clojure Formatting rules](https://tonsky.me/blog/clojurefmt/). It doesn’t require REPL connection, any Clojure runtime or external tools.
3239

3340
To reformat whole file, run `Clojure Sublimed: Reindent Buffer`.
3441

35-
To reindent only current line(s), run `Clojure Sublimed: Reindent Lines`.
42+
To reindent only selected line(s), run `Clojure Sublimed: Reindent Lines`.
3643

37-
To enable reindenting / formatting on save, add `format_on_save: true` to settings. ([See how to edit settings](#editing-settings))
44+
To enable reindenting/formatting on save, add `format_on_save: true` to settings. ([See how to edit settings](#editing-settings))
3845

3946
To enable correct indentations as you type code, rebind `Enter` to `Clojure Sublimed: Insert Newline`:
4047

@@ -48,15 +55,14 @@ To enable correct indentations as you type code, rebind `Enter` to `Clojure Subl
4855

4956
Best way to do it is through running `Preferences: Clojure Sublimed Key Bindings`.
5057

51-
## nREPL Client
58+
## REPL clients
5259

53-
Clojure Sublimed nREPL client enables interactive development from the comfort of your editor.
60+
Clojure Sublimed REPL clients enable interactive development from the comfort of your editor.
5461

5562
Principles:
5663

5764
- Minimal distraction. Display evaluation results inline.
5865
- Decomplected. Eval code and nothing more.
59-
- Server-agnostic. We work with any nREPL socket, local or over network.
6066

6167
Features:
6268

@@ -69,23 +75,30 @@ Features:
6975
- [x] show evaluation time,
7076
- [x] bind keys to eval arbitrary code.
7177

78+
Clojure Sublimed has four REPL clients:
79+
80+
1. Raw nREPL: no extra middlewares, could work with any nREPL server.
81+
2. JVM nREPL: only works with JVM server.
82+
3. ShadowCLJS nREPL: works with ShadowCLJS
83+
4. JVM Socket REPL: works with raw Socket REPL on JVM
84+
85+
All four support same basic features (eval, lookup, interrupt on JVM), maybe with slightly different quality of implementation.
86+
87+
How to choose which REPL to use?
88+
89+
1. Are you on JVM? Use Socket REPL.
90+
2. CLJS? Use ShadowCLJS REPL.
91+
3. Only have basic nREPL? Use Raw nREPL.
92+
4. JVM nREPL is mostly a carryover from Clojure Sublime v1-2 and is now superseded by Socket REPL. Works better than Raw nREPL but worse than Socket REPL.
93+
7294
We intentionally excluded following features:
7395

7496
- [ ] Autocomplete. Static analysis is much simpler and much more reliable than requiring an always-live connection to the working app.
7597

7698
Look at [Sublime LSP](https://github.com/sublimelsp/LSP) with [Clojure LSP](https://github.com/clojure-lsp/clojure-lsp) or [SublimeLinter](https://github.com/SublimeLinter/SublimeLinter) with [clj-kondo](https://github.com/ToxicFrog/SublimeLinter-contrib-clj-kondo) if you need autocompletion.
7799

78-
Why nREPL and not Socket Server REPL/pREPL/unREPL?
79-
80-
- nREPL has the widest adoption,
81-
- nREPL is machine-friendly,
82-
- nREPL comes with batteries included (interrupt, load-file, sideload),
83-
- nREPL is extensible via middleware,
84-
- nREPL serialization is easier to access from Python than EDN.
85-
86100
Differences from [Tutkain](https://tutkain.flowthing.me/):
87101

88-
- nREPL instead of Socket Server REPL
89102
- Does not have separate REPL panel
90103
- Keeps multiple eval results on a screen simultaneously
91104
- Can show stack traces inline in editor
@@ -94,30 +107,23 @@ Differences from [Tutkain](https://tutkain.flowthing.me/):
94107
- Can eval infinite sequences
95108
- Redirects all `*out*`/`*err*` to `System.out`/`System.err`
96109

97-
## Installation
98-
99-
1. `Package Control: Install Package``Clojure Sublimed`
100-
101-
2. Assign syntax to Clojure files:
102-
103-
- open any clj/cljc/cljs file,
104-
- run `View``Syntax``Open all with current extension as...``Clojure Sublimed``Clojure (Sublimed)`.
105-
106110
## How to use
107111

108-
Important! Make sure you switched your syntax to `Clojure (Sublimed)`.
112+
For Clojure apps:
109113

110-
For Clojure apps
114+
1. Run Socket Server, e.g. with `clj -X clojure.core.server/start-server :name repl :port 5555 :accept clojure.core.server/repl :server-daemon false`
115+
2. Run `Clojure Sublimed: Connect to Socket REPL` command.
111116

112-
1. Run nREPL server.
113-
2. Run `Clojure Sublimed: Connect` command.
114-
115-
For Shadow-cljs apps
117+
For Shadow-cljs apps:
116118

117119
1. Run `shadow-cljs watch app`. (This starts a HTTP server and an nREPL)
118120
2. If you are building a web-app, open the http-server url (from step 1) in the browser. This connects the shadow server to JS runtime.
119-
3. Run `Clojure Sublimed: Connect shadow-cljs` command from sublime's command palette.
121+
3. Run `Clojure Sublimed: Connect shadow-cljs` command.
120122

123+
For other nREPL apps:
124+
125+
1. Run nREPL server.
126+
2. Run `Clojure Sublimed: Connect to raw nREPL` command.
121127

122128
### Evaluating code from buffer
123129

@@ -139,7 +145,7 @@ You don’t have to wait for one form to finish evaluating to evaluate something
139145

140146
<img src="https://raw.github.com/tonsky/Clojure-Sublimed/master/screenshots/eval_parallel.gif" width="353" height="151" alt="Evaluate in Parallel">
141147

142-
By default, Clojure Sublimed will also print evaluation time if it took more than 100 ms:
148+
By default, Clojure Sublimed will also print evaluation time if it takes more than 100 ms:
143149

144150
<img src="https://raw.github.com/tonsky/Clojure-Sublimed/master/screenshots/eval_elapsed.png" width="500" height="139" alt="Elapsed time">
145151

@@ -183,12 +189,14 @@ To support such use cases, Clojure Sublimed allows you to bind arbitrary piece o
183189
"args": {"code": "(clojure.test/run-all-tests)"}}
184190
```
185191

186-
Then, whenever you press <key>Ctrl</key> + <key>T</key>, you’ll see the result in the status bar, like this:
192+
Then, whenever you press <kbd>Ctrl</kbd> + <kbd>T</kbd>, you’ll see the result in the status bar, like this:
187193

188194
<img src="https://raw.github.com/tonsky/Clojure-Sublimed/master/screenshots/eval_code.png" width="536" height="37" alt="Eval Code">
189195

190196
Tip: use `(clojure.test/run-all-tests (re-pattern (str *ns*))))` to run tests in current namespace.
191197

198+
Tip: bind `(user/reload)` to <kbd>Cmd</kbd> <kbd>R</kbd> to reload your app with tools.namespace.
199+
192200
### Clearing results
193201

194202
Finally, to clear evaluation results run `Clojure Sublimed: Clear Evaluation Results`.
@@ -209,7 +217,7 @@ This will be applied to every evaluation.
209217

210218
## Default Key Bindings
211219

212-
Clojure Sublimed comes with no keybindings enabled by default to guarantee they won’t conflict with any other extension.
220+
Clojure Sublimed comes with no keybindings enabled by default to guarantee they won’t conflict with any other extension (Sublime Text’s limitation).
213221

214222
This is the recommended keymap:
215223

@@ -226,12 +234,20 @@ Reindent Buffer | <kbd>Ctrl</kbd> <kbd>Shift</kbd> <kbd>F</kbd> |
226234

227235
To set it up, run `Preferences: Clojure Sublimed Key Bindings` command and copy example keybindings to your local Key Bindings file.
228236

237+
## stdout/stderr
238+
239+
Clojure Sublimed does things a little different when it comes to stdout. Normally REPL would show you all stdout/stderr that originated from your session. I find it confusing, because it doesn’t always work and you have to check two places for output. Moreover, there’s no output panel, so there’s no place to show stdout anyway.
240+
241+
So instead, Clojure Sublimed _does not_ redirect neither stdout nor stderr. Check original console to see what was printed there.
242+
243+
<img src="https://raw.github.com/tonsky/Clojure-Sublimed/master/screenshots/stdout.png" width="616" height="588" alt="Stdout redirect">
244+
229245
## Frequently Asked Questions
230246

231247
Q: REPL/eval doesn’t work
232248

233249
A: Make sure you are using nREPL 0.9 or later.
234-
A: Make sure you have assigned `Clojure (Sublimed)` syntax to the file.
250+
A: Also check console (<kbd>Cmd</kbd> <kbd>\`</kbd>) for errors
235251

236252
## Credits
237253

screenshots/stdout.png

348 KB
Loading

test_repl/forms.clj

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@
3434
(do (Thread/sleep 990) :fifth)
3535
(do (Thread/sleep 490) :sixth)
3636
(do (Thread/sleep 90) :seventh)
37+
(do (Thread/sleep 45) :eigths)
38+
39+
(defn x)
3740

3841
; infinite sequence
3942
(range)
@@ -52,7 +55,8 @@
5255
; throw exception
5356
(throw (ex-info
5457
"abc" {:a 1}))
55-
(throw (Exception. "ex with msg"))
58+
#?(:clj (throw (Exception. "ex with msg"))
59+
:cljs (throw (js/Error. "ex with msg")))
5660
*e
5761
(/ 1 0)
5862

0 commit comments

Comments
 (0)