guns / vim-clojure-static

Meikel Brandmeyer's excellent Clojure runtime files

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Indention of nested vectors

palango opened this issue · comments

When working with hiccup I often end up with multiple nested vectors. Usually for each nesting level a space is added what makes sense if values would be contained. However I would like a increased indention by two spaces. Is that somehow possible currently or what do you think about that?

What is:

[:p
 |

What should be:

[:p
  |

I admit I've wanted the same indentation style in the past when
working with Hiccup vectors, but the current indentation is logically
consistent:

Clojure literal [] and {} forms are always data (unlike parens which are
usually function calls, but sometimes lists). Indentation in multiline
function calls are meant to highlight this distinction, so the current
implementation does not do fn-indent for literal vectors, maps, or lists
(where the first argument is a literal collection).

That said, I do sympathize. Hiccup forms are more readable when indented
in the fn-indent style. However, what information could the indentexpr
use to determine if this is a Hiccup form or a plain vector? The first
element is usually a keyword, but it could also be a symbol, string, or
even a composite expression. If we constrain our match to vectors that
begin with a keyword, it would match too wide since passing around a
literal vector of keywords is quite common.

Defaulting to fn-indent for vectors is not acceptable, but if there
was a good way to identify vectors that should be fn-indented, I would
strongly consider adding it.

Thanks for the report!

Thanks for the explanation, why this works as it works is now clear to me.