Fork me on GitHub
#humbleui
<
2023-01-18
>
Brandon Olivier18:01:27

This is a somewhat trivial concern, but what are y'all doing to get good indentation with HumbleUI? I'm using Emacs, but I'm interested to hear what folks on VSCode or Intellij do too.

Niki20:01:51

Do you mean something extra on top of just normal clojure indentation?

Brandon Olivier20:01:35

Technically no, but I noticed a disconnect between the clojure-mode default indentation for functions and the preferred indentation for HumbleUI.

(ui/dynamic ctx [{:keys [leading]} ctx]
            (ui/rect (paint/fill 0xFFB2D7FE)
                     (ui/center (ui/padding 10 leading)
                                (ui/label text))))
Is the default behavior I'm seeing, but the docs look more like
(ui/dynamic ctx [{:keys [leading]} ctx]
  (ui/rect (paint/fill 0xFFB2D7FE)
    (ui/center (ui/padding 10 leading)
               (ui/label text))))

Brandon Olivier20:01:49

I can technically fix it with define-clojure-indent but that seems fragile since it's based on symbols and not associated with the var

Niki20:01:12

I can add meta to dynamic if you need it

Niki20:01:46

That’s probably because dynamic is a macro and per bbatsov style macros indent content by first arg

Niki20:01:16

I use different convention when everything is indented 2 spaces from paren

Brandon Olivier20:01:01

Do other ui elements have multiple args? It's more the multiple args rather than the macro behavior, I think

Niki20:01:09

That’s why examples are that way

Brandon Olivier20:01:13

I've read that before 😉

Brandon Olivier20:01:47

Pretty much all my Clojure is for personal stuff, so I tend to use whatever the Emacs defaults are

Niki20:01:08

Yeah you might be right, it’s first arg by default and some macros make an exception to that

Niki20:01:43

like when etc

Brandon Olivier20:01:15

I've managed not to have real-world issues with define-clojure-indent in both Rum and Fulcro, so maybe it's a moot point.