diff options
author | Adam Stankiewicz <sheerun@sher.pl> | 2016-07-19 10:09:54 +0200 |
---|---|---|
committer | Adam Stankiewicz <sheerun@sher.pl> | 2016-07-19 10:09:54 +0200 |
commit | 11f34624aa32ac72dc65e46ea9badb4b16a0edd1 (patch) | |
tree | 63c50a215fe4a67e4223c19b4b1dbb9747c14ffd /indent/blade.vim | |
parent | 1422f7a75ce0b382d601238c5979b04473b9021e (diff) | |
download | vim-polyglot-2.11.3.tar.gz vim-polyglot-2.11.3.zip |
Updatev2.11.3
Diffstat (limited to 'indent/blade.vim')
-rw-r--r-- | indent/blade.vim | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/indent/blade.vim b/indent/blade.vim index d578a432..97f7f293 100644 --- a/indent/blade.vim +++ b/indent/blade.vim @@ -18,9 +18,18 @@ unlet! b:did_indent let b:did_indent = 1 +" Doesn't include 'foreach' and 'forelse' because these already get matched by 'for'. +let s:directives_start = 'if\|else\|unless\|for\|while\|empty\|push\|section\|can\|hasSection\|verbatim' +let s:directives_end = 'else\|end\|empty\|show\|stop\|append\|overwrite' + +if exists('g:blade_custom_directives_pairs') + let s:directives_start .= '\|' . join(keys(g:blade_custom_directives_pairs), '\|') + let s:directives_end .= '\|' . join(values(g:blade_custom_directives_pairs), '\|') +endif + setlocal autoindent setlocal indentexpr=GetBladeIndent() -setlocal indentkeys=o,O,*<Return>,<>>,!^F,=@else,=@end,=@empty,=@show,=@stop +exe "setlocal indentkeys=o,O,<>>,!^F,0=}},0=!!},=@" . substitute(s:directives_end, '\\|', ',=@', 'g') " Only define the function once. if exists("*GetBladeIndent") @@ -36,18 +45,21 @@ function! GetBladeIndent() let line = substitute(substitute(getline(lnum), '\s\+$', '', ''), '^\s\+', '', '') let cline = substitute(substitute(getline(v:lnum), '\s\+$', '', ''), '^\s\+', '', '') let indent = indent(lnum) - if cline =~# '@\%(else\|elseif\|empty\|end\|show\|stop\)' || + if cline =~# '@\%(' . s:directives_end . '\)' || \ cline =~# '\%(<?.*\)\@<!?>\|\%({{.*\)\@<!}}\|\%({!!.*\)\@<!!!}' let indent = indent - &sw - elseif line =~# '<?\%(.*?>\)\@!' + elseif line =~# '<?\%(.*?>\)\@!\|@php\%(\s*(\)\@!' let indent = indent + &sw else if exists("*GetBladeIndentCustom") let hindent = GetBladeIndentCustom() - elseif searchpair('@include\s*(', '', ')', 'bWr') || + " Don't use PHP indentation if line is a comment + elseif line !~# '^\s*\%(#\|//\)\|\*/\s*$' && ( + \ searchpair('@include\%(If\)\?\s*(', '', ')', 'bWr') || \ searchpair('{!!', '', '!!}', 'bWr') || \ searchpair('{{', '', '}}', 'bWr') || - \ searchpair('<?', '', '?>', 'bWr') + \ searchpair('<?', '', '?>', 'bWr') || + \ searchpair('@php\%(\s*(\)\@!', '', '@endphp', 'bWr') ) execute 'let hindent = ' . s:phpindent else execute 'let hindent = ' . s:htmlindent @@ -60,7 +72,7 @@ function! GetBladeIndent() if line =~# '@\%(section\)\%(.*@end\)\@!' && line !~# '@\%(section\)\s*([^,]*)' return indent - elseif line =~# '@\%(if\|elseif\|else\|unless\|foreach\|forelse\|for\|while\|empty\|push\|section\|can\|hasSection\)\%(.*@end\|.*@stop\)\@!' || + elseif line =~# '@\%(' . s:directives_start . '\)\%(.*@end\|.*@stop\)\@!' || \ line =~# '{{\%(.*}}\)\@!' || line =~# '{!!\%(.*!!}\)\@!' return increase else |