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/dart.vim | |
parent | 74652b465d7eff97070001317a4ea5557717378d (diff) | |
download | vim-polyglot-e404a658b1647fad396a954776eda0bdabf8353c.tar.gz vim-polyglot-e404a658b1647fad396a954776eda0bdabf8353c.zip |
Update
Diffstat (limited to 'indent/dart.vim')
-rw-r--r-- | indent/dart.vim | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/indent/dart.vim b/indent/dart.vim index af4cb7df..601abbb0 100644 --- a/indent/dart.vim +++ b/indent/dart.vim @@ -8,6 +8,32 @@ let b:did_indent = 1 setlocal cindent setlocal cinoptions+=j1,J1 +setlocal indentexpr=DartIndent() + let b:undo_indent = 'setl cin< cino<' +if exists("*DartIndent") + finish +endif + +function! DartIndent() + " Default to cindent in most cases + let indentTo = cindent(v:lnum) + + let previousLine = getline(prevnonblank(v:lnum - 1)) + let currentLine = getline(v:lnum) + + " Don't indent after an annotation + if previousLine =~# '^\s*@.*$' + let indentTo = indent(v:lnum - 1) + endif + + " Indent after opening List literal + if previousLine =~# '\[$' && !(currentLine =~# '^\s*\]') + let indentTo = indent(v:lnum - 1) + &shiftwidth + endif + + return indentTo +endfunction + endif |