shaunlebron / parinfer-codemirror

Parinfer layer for CodeMirror
ISC License
16 stars 4 forks source link

What is the hotkey to toggle modes #12

Closed dustingetz closed 5 years ago

shaunlebron commented 5 years ago

never actually thought to setup a hotkey by default. you have to bind it yourself to the function to switch modes

dustingetz commented 5 years ago

For the next guy, here is how I did it:

(if (and (:parinfer props) (= "clojure" (:mode props)))
  (do
    (js/parinferCodeMirror.init ref)
    ; `mode` is 'paren', 'indent', or 'smart'
    (.addKeyMap ref #js {"Ctrl-1" #(let [mode (goog.object/getValueByKeys ref "__parinfer__" "mode")
                                         mode (case mode "paren" "indent" "paren")]
                                     (js/parinferCodeMirror.setMode ref mode))})))
dustingetz commented 5 years ago

The problem is that you need a visual indicator to indicate what mode you're in (in addition to the hotkey). I was able to abuse the locus functionality to accomplish this - it shows the locus when in indent mode. Here is the final result - Watch for the locus toggling, it is subtle! This is really cool!

I am not sure what will come of this, but for the next guy, my hacks are here: https://github.com/hyperfiddle/hyperfiddle/blob/e50b7407be464995eb3bf62c843e230911cb13e6/src/contrib/ui/codemirror.cljs#L44-L49

xpdc4wy

dustingetz commented 5 years ago

@shaunlebron Can I contact you by email?

shaunlebron commented 5 years ago

yes

On Mon, Aug 13, 2018 at 9:53 AM Dustin Getz notifications@github.com wrote:

@shaunlebron https://github.com/shaunlebron Can I contact you by email?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/shaunlebron/parinfer-codemirror/issues/12#issuecomment-412546530, or mute the thread https://github.com/notifications/unsubscribe-auth/AAHIZlhIumNsj8hEbxhxHWxLc-Ou6j-Xks5uQZLmgaJpZM4VlLdl .

dustingetz commented 5 years ago

@shaunlebron what is your email