Fork me on GitHub
#vim
<
2023-01-03
>
Braden Shepherdson16:01:40

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?

practicalli-johnny17:01:05

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.

👆 2
Noah Bogart17:01:22

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