humbleui

Brandon Olivier 2023-01-18T18:28:27.034949Z

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.

Niki 2023-01-18T20:29:51.603049Z

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

Brandon Olivier 2023-01-18T20:33:35.322639Z

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 Olivier 2023-01-18T20:34:49.111659Z

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

Niki 2023-01-18T20:43:12.911079Z

I can add meta to dynamic if you need it

Niki 2023-01-18T20:43:46.820399Z

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

Niki 2023-01-18T20:44:16.393199Z

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

Niki 2023-01-18T20:44:58.714449Z

described here https://tonsky.me/blog/clojurefmt/

Brandon Olivier 2023-01-18T20:45:01.704069Z

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

Niki 2023-01-18T20:45:09.767539Z

That’s why examples are that way

Brandon Olivier 2023-01-18T20:45:13.960689Z

I've read that before 😉

Brandon Olivier 2023-01-18T20:45:47.893059Z

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

Niki 2023-01-18T20:46:08.423129Z

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

Niki 2023-01-18T20:48:43.267239Z

like when etc

Brandon Olivier 2023-01-18T20:49:15.021809Z

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.