diff options
author | Adam Stankiewicz <sheerun@sher.pl> | 2016-12-20 20:57:20 +0100 |
---|---|---|
committer | Adam Stankiewicz <sheerun@sher.pl> | 2016-12-20 20:57:20 +0100 |
commit | e404a658b1647fad396a954776eda0bdabf8353c (patch) | |
tree | fcdab0e324fd72015ba656e43bd8f8c243030c14 /indent/plantuml.vim | |
parent | 74652b465d7eff97070001317a4ea5557717378d (diff) | |
download | vim-polyglot-e404a658b1647fad396a954776eda0bdabf8353c.tar.gz vim-polyglot-e404a658b1647fad396a954776eda0bdabf8353c.zip |
Update
Diffstat (limited to '')
-rw-r--r-- | indent/plantuml.vim | 59 |
1 files changed, 30 insertions, 29 deletions
diff --git a/indent/plantuml.vim b/indent/plantuml.vim index 3e0f455d..93ecb8cb 100644 --- a/indent/plantuml.vim +++ b/indent/plantuml.vim @@ -14,45 +14,46 @@ if exists("*GetPlantUMLIndent") endif let s:incIndent = - \ '^\s*\(loop\|alt\|opt\|group\|critical\|else\|legend\|box\)\>\|' . - \ '^\s*\([hr]\?note\|ref\)\>[^:]*$\|' . - \ '^\s*title\s*$\|' . - \ '^\s*skinparam\>.*{\s*$\|' . - \ '^\s*state\>.*{' + \ '^\s*\%(loop\|alt\|opt\|group\|critical\|else\|legend\|box\|if\|while\)\>\|' . + \ '^\s*ref\>[^:]*$\|' . + \ '^\s*[hr]\?note\>\%(\%("[^"]*" \<as\>\)\@![^:]\)*$\|' . + \ '^\s*title\s*$\|' . + \ '^\s*skinparam\>.*{\s*$\|' . + \ '^\s*\%(state\|class\|partition\|rectangle\)\>.*{' -let s:decIndent = '^\s*\(end\|else\|}\)' +let s:decIndent = '^\s*\%(end\|else\|}\)' function! GetPlantUMLIndent(...) abort - "for current line, use arg if given or v:lnum otherwise - let clnum = a:0 ? a:1 : v:lnum - - if !s:insidePlantUMLTags(clnum) - return indent(clnum) + "for current line, use arg if given or v:lnum otherwise + let clnum = a:0 ? a:1 : v:lnum + + if !s:insidePlantUMLTags(clnum) + return indent(clnum) + endif + + let pnum = prevnonblank(clnum-1) + let pindent = indent(pnum) + let pline = getline(pnum) + let cline = getline(clnum) + + if cline =~ s:decIndent + if pline =~ s:incIndent + return pindent + else + return pindent - shiftwidth() endif - let pnum = prevnonblank(clnum-1) - let pindent = indent(pnum) - let pline = getline(pnum) - let cline = getline(clnum) - - if cline =~ s:decIndent - if pline =~ s:incIndent - return pindent - else - return pindent - shiftwidth() - endif - - elseif pline =~ s:incIndent - return pindent + shiftwidth() - endif + elseif pline =~ s:incIndent + return pindent + shiftwidth() + endif - return pindent + return pindent endfunction function! s:insidePlantUMLTags(lnum) abort - call cursor(a:lnum, 1) - return search('@startuml', 'Wbn') && search('@enduml', 'Wn') + call cursor(a:lnum, 1) + return search('@startuml', 'Wbn') && search('@enduml', 'Wn') endfunction endif |