This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-01-03
Channels
- # adventofcode (2)
- # announcements (1)
- # asami (35)
- # babashka (67)
- # beginners (97)
- # cherry (3)
- # clj-yaml (3)
- # cljsrn (9)
- # clojure (44)
- # clojure-dev (34)
- # clojure-europe (13)
- # clojure-gamedev (1)
- # clojure-norway (10)
- # clojure-uk (2)
- # clojurescript (24)
- # clr (1)
- # conjure (18)
- # cursive (4)
- # datalevin (3)
- # emacs (6)
- # graalvm (9)
- # graphql (1)
- # introduce-yourself (1)
- # malli (7)
- # nrepl (3)
- # portal (1)
- # quil (2)
- # reagent (1)
- # reitit (21)
- # releases (1)
- # reveal (11)
- # ring (2)
- # shadow-cljs (17)
- # sql (24)
- # vim (4)
I've been happily using the indentation-fixing command of vim-sexp
for years, but its lack of configuration is letting me down in a specific, slightly nonstandard case.
Metabase's style is to use a single space indent in vertically stacked (lists)
, like for [vectors]
and {maps}
. so for example we want an ns
to look like
(ns metabase.shared.util.log
(:require
[goog.log :as glog]
; ...
[lambdaisland.glogi.console :as glogi-console])
(:require-macros
[metabase.shared.util.log]))
but if I use ==
and friends from vim-sexp
the :require
lines get indented by two spaces:
(ns metabase.shared.util.log
(:require
[goog.log :as glog]
; ...
[lambdaisland.glogi.console :as glogi-console])
(:require-macros
[metabase.shared.util.log]))
I can shell out to cljfmt
to fix it, but that's slow and clunky. I use Conjure and nREPL. (I know vim-iced has some more powerful indentation through cider-refactor. I may have to look into that, but I moved away from vim-iced to straight Conjure when I was having REPL-juggling issues last year.)
are there any nicer ways to get configurable Clojure indentation?I use clojure-lsp format as I type and use https://github.com/greglook/cljstyle in the terminal before committing, cljstyle is very snappy as its a binary and also available in the https://github.com/DeLaGuardo/setup-clojure. https://github.com/practicalli/clojure-app-template/blob/main/.cljstyle. Its very similar to cljfmt in rules, but I find the configuration far easier to understand.
https://github.com/guns/vim-clojure-static#gclojure_align_subforms I think you're looking for this
My company's codebase is similar tho we use zprint
. I've taken to just letting the indentation be wrong while I develop, and then calling our binstub bin/zprint-changed
to format all touched files before committing