I've successfully gotten vim to understand my language's syntax for highlighting, but I'm unsure how to get it to automatically indent my code properly. The language itself is somewhat Lisp-like, but it uses both brackets []
and parentheses ()
as delimiters. The resulting code indentation should look something like this:
[foo [bar baz] [qux
[do a thing]
[more doing a thing]
[^ ()
; some stuff here
[foobar]]]]
[back to here]
Basically, each unclosed bracket or parenthesis should indent the line by two spaces. Closing said delimiter should decrease the following lines by the same amount.
I've looked into autoindent
, but it doesn't seem sufficient for what I'd like to do, unless I'm missing something. The alternative, indentexpr
, seems more promising, but I don't think I understand how to use it.
How can I get a working indentation system for my syntax?