nextjournal / clojure-mode

Clojure/Script mode for CodeMirror 6
https://nextjournal.github.io/clojure-mode/
Eclipse Public License 2.0
158 stars 19 forks source link

Stupid question. But how do I actually use this? #36

Closed interstar closed 1 year ago

interstar commented 1 year ago

This is the first time I'm trying to use CodeMirror in a project. So I'm a bit confused by the whole process.

I have CodeMirror in my project via cljsjs/codemirror

I've added the dependency for this clojure-mode to my deps.edn. And it looks like it's installing it.

        cljsjs/codemirror {:mvn/version "5.44.0-1"}

        io.github.nextjournal/clojure-mode
            {:git/sha "1f55406087814a0dda6806396aa596dbe13ea302"}

And I'm creating the component like this :

(.fromTextArea js/CodeMirror.
                      (rdom/dom-node this)
                      (clj->js {:lineNumbers true
                                :mode "clojure"
                                :value init-code}))

And CodeMirror is working. But I don't see any syntax colouring or other Clojure specific behaviour. So is there something else I have to do to include and activate this mode in CM?

All the online tutorials I find suggest that just saying :mode "clojure" should put CM into Clojure mode. But is this Nextjournal mode actually called something else?

mk commented 1 year ago

This code is for CodeMirror 6, not version 5 which you tried to use.

You can use it with shadow-cljs in your project. One thing you can try is copying the code from demo https://github.com/nextjournal/clojure-mode/tree/7b911bf6feab0f67b60236036d124997627cbe5e/demo along with the relevant build from https://github.com/nextjournal/clojure-mode/blob/7b911bf6feab0f67b60236036d124997627cbe5e/shadow-cljs.edn#L6-L10