From b5300c31344d0012995f7e44fa35a979e7abf5ad Mon Sep 17 00:00:00 2001 From: YohananDiamond Date: Fri, 18 Jun 2021 23:16:14 -0300 Subject: [PATCH] First attempt at fixing "lone" elses Very much a work in progress, but seems to be going well. --- indent/zig.vim | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/indent/zig.vim b/indent/zig.vim index 3101840..17701c8 100644 --- a/indent/zig.vim +++ b/indent/zig.vim @@ -45,6 +45,31 @@ function! GetZigIndent(lnum) let prevLineNum = prevnonblank(a:lnum-1) let prevLine = getline(prevLineNum) + " for lines that begin with an `else`: + if currentLine =~ '\v^\s*else>' + " TODO: explain the process + " FIXME: would this cause uneeded slowdowns? + let indentLimit = indent(prevLineNum) + let lineNum = prevLineNum + while 1 + let lineNum = prevnonblank(lineNum-1) + if lineNum < 1 + return -1 + endif + + let line = getline(lineNum) + + let lineNumIndent = indent(lineNum) + if lineNumIndent < indentLimit + if line =~ '\v' + return lineNumIndent + endif + + return -1 + endif + endwhile + endif + " for lines that look like " }, " };