I've finished installing parinfer.. It was tricky. I'm stuck however when it comes to being able to toggle between parinfer-clojure
and clojure
modes with CodeMirror. @chrisoakman @shaunlebron Do you guys have any pointers?
Shaun would probably know; I haven't worked with CodeMirror
Is that like a language-pack setting?
I'm not sure what a language-pack setting is, however those modes are codemirror options. When reloading the component that hosts the textarea I'm using to create the codemirror instance, the codemirror instantiation code doesn't run. I think it's because of this: https://gitlab.com/escherize/cljsfiddle/blob/codemirror-with-parinfer/src/cljs/cljsfiddle/parinfer_codemirror/example.cljs#L44
I'm curious about why it matters if the state is there or not.
I'll remove it and find out :simple_smile:
oh - it gets out of sync with its backing atom..
small trick: I would replace (js/document.getElementById element-id)
with (by-id element-id)
and just create a by-id
wrapper around the native DOM call
less verbose :simple_smile:
sounds good. Untill I can toggle parinfer on/off (some of the repls do... I can't figure it out though), I'll keep the codemirror instance with clojure
mode.
hmm, I didn’t realize that parinfer-codemirror was just using code from the website
I was hoping it was a proper codemirror plugin instead of the wrapper that I used to tightly control the state just for animations
regardless it’s what we have...
@escherize: use cm.setOption
to change the mode: http://codemirror.net/doc/manual.html#setOption
hey @shaunlebron - oh wow is that really all it takes?
cm.setOption(“mode”, …)
I think so
I'll give it a go :]
Is there a good way to grab the cm instance from anywhere?
I always kept a reference to it in a lookup atom by id
but there’s only one in cljsfiddle, so just save the cm instance somewhere when creating it
@escherize: https://gitlab.com/escherize/cljsfiddle/blob/codemirror-with-parinfer/src/cljs/cljsfiddle/state.cljs#L10
(-> @state editor-key :cm)
👍:skin-tone-3:
I’ll look at this more tomorrow. gotta go to bed
great stuff man!
Thanks - I've noticed that changing the mode didn't actually change the parinfer-y behavior of the editor, though. We'll catchup on it tomorrow
@escherize we have a code mirror + re-frame lib coming out soon but still in the making, hopefully next week we will publish it ok?
parinfer-clojure
is just a modification of clojure
that allows us to highlight close-parens at the end of a line differently
all the parinfer events are manually attached to the cm events
parinfer is not a proper codemirror mode