hare.vim

[vim] Hare vim plugin
git clone https://git.torresjrjr.com/hare.vim.git
Log | Files | Refs | README | LICENSE

commit 2681e67977fea9d1908a816e48a1cf688d450529
parent d15cbd00575bc517dfd54d1d27a4de18223e3a9c
Author: Sebastian <sebastian@sebsite.pw>
Date:   Wed,  2 Mar 2022 23:14:54 -0500

Indent top level declaration after =

Signed-off-by: Sebastian <sebastian@sebsite.pw>

Diffstat:
Mindent/hare.vim | 11+++++++++++
1 file changed, 11 insertions(+), 0 deletions(-)

diff --git a/indent/hare.vim b/indent/hare.vim @@ -52,6 +52,17 @@ function! GetHareIndent() " This is all very hacky and imperfect, but it's tough to do much better when " working with regex-based indenting rules. + " If the previous line ended with =, indent by one shiftwidth. + if prevline =~# '\v\=\s*(//.*)?$' + return indent(prevlnum) + shiftwidth() + endif + + " If the previous line ended in a semicolon and the line before that ended + " with =, deindent by one shiftwidth. + if prevline =~# '\v;\s*(//.*)?$' && prevprevline =~# '\v\=\s*(//.*)?$' + return indent(prevlnum) - shiftwidth() + endif + " TODO: The following edge-case is still indented incorrectly: " case => " if (foo) {