Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing indentation on empty brackets with trailing comma/colon (issue #42) #56

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 2 additions & 9 deletions indent/zig.vim
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,12 @@ function! GetZigIndent(lnum)
" },
" };
" try treat them the same as a }
if prevLine =~ '\v^\s*},$'
if currentLine =~ '\v^\s*};$' || currentLine =~ '\v^\s*}$'
if prevLine =~ '\v^\s*}\s*[,;]\s*$'
if currentLine =~ '\v^\s*}\s*[,;]?\s*$'
return indent(prevLineNum) - 4
endif
return indent(prevLineNum-1) - 4
Copy link
Contributor Author

@yohannd1 yohannd1 Jun 13, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By the way - I haven't modified this specific line (l. 56) but I'm curious: wouldn't it be better if it were indent(prevLineNum)? As far as I understood it gets the indentation inside the previous block and deindents it by one level, which I believe should result in the same as indent(PrevLineNum).

endif
if currentLine =~ '\v^\s*},$'
return indent(prevLineNum) - 4
endif
if currentLine =~ '\v^\s*};$'
return indent(prevLineNum) - 4
endif


" cindent doesn't handle this case correctly:
" switch (1): {
Expand Down