Skip to content

Commit ed3ef78

Browse files
committed
Add Vim indent file.
1 parent f7d564c commit ed3ef78

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

misc/vim/indent/metafacture-fix.vim

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
" Only load this indent file when no other was loaded yet.
2+
if exists("b:did_indent")
3+
finish
4+
endif
5+
let b:did_indent = 1
6+
7+
setlocal indentexpr=GetMetafactureFixIndent()
8+
setlocal indentkeys+=0=do,0=if,0=unless,0=elsif,0=else,0=end
9+
10+
let b:undo_indent = "setlocal indentexpr< indentkeys<"
11+
12+
if exists("*GetMetafactureFixIndent")
13+
finish
14+
endif
15+
16+
function! GetMetafactureFixIndent()
17+
let lnum = prevnonblank(v:lnum - 1)
18+
19+
if lnum == 0
20+
return 0
21+
endif
22+
23+
if synIDattr(synID(v:lnum, 1, 1), "name") =~ '^fixComment*'
24+
return indent(v:lnum)
25+
endif
26+
27+
let new_indent = indent(lnum)
28+
29+
if getline(lnum) =~ '^\s*\(\(do\|if\|unless\|elsif\)\>\|else$\)\|($'
30+
let new_indent += shiftwidth()
31+
endif
32+
33+
if getline(v:lnum) =~ '^\s*\(elsif\>\|\(else\|end\|)\)$\)'
34+
let new_indent -= shiftwidth()
35+
endif
36+
37+
return new_indent
38+
endfunction

misc/vim/syntax/metafacture-fix.vim

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ syn region fixDoubleQuotedString start=/\v"/ skip=/\v\\./ end=/\v"/
1919
syn region fixIfBlock start="if" end="end" fold transparent
2020
syn region fixSingleQuotedString start=/\v'/ skip=/\v\\./ end=/\v'/
2121

22+
syn sync ccomment fixCommentRegion
23+
2224
hi link fixBareString String
2325
hi link fixBind Keyword
2426
hi link fixComment Comment

0 commit comments

Comments
 (0)