Skip to content

Commit

Permalink
Update indent to 1.36
Browse files Browse the repository at this point in the history
  • Loading branch information
hlissner committed May 6, 2013
1 parent 0183628 commit db30d6b
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions indent/php.vim
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@
" Language: PHP
" Author: John Wellesz <John.wellesz (AT) teaser (DOT) fr>
" URL: http://www.2072productions.com/vim/indent/php.vim
" Last Change: 2011 October 23rd
" Last Change: 2013 February 23rd
" Newsletter: http://www.2072productions.com/?to=php-indent-for-vim-newsletter.php
" Version: 1.35
" Version: 1.36
"
" Changes: 1.36 - Added support for short array declaration (Thanks to
" Warren Seymour)
"
" Changes: 1.35 - New option: PHP_outdentSLComments to add extra
" indentation to single-line comments.
Expand Down Expand Up @@ -668,7 +671,7 @@ function! IslinePHP (lnum, tofind) " {{{
endif
endfunction " }}}

let s:notPhpHereDoc = '\%(break\|return\|continue\|exit\|else\)'
let s:notPhpHereDoc = '\%(break\|return\|continue\|exit\|die\|else\)'
let s:blockstart = '\%(\%(\%(}\s*\)\=else\%(\s\+\)\=\)\=if\>\|else\>\|while\>\|switch\>\|case\>\|default\>\|for\%(each\)\=\>\|declare\>\|class\>\|interface\>\|abstract\>\|try\>\|catch\>\)'

" make sure the options needed for this script to work correctly are set here
Expand Down Expand Up @@ -812,7 +815,7 @@ function! GetPhpIndent()
let b:InPHPcode = 0
let b:UserIsTypingComment = 0
" Then we have to find a php start tag...
let b:InPHPcode_tofind = '<?\%(.*?>\)\@!\|<script.*>'
let b:InPHPcode_tofind = s:PHP_startindenttag
endif
endif "!b:InPHPcode_checked }}}

Expand Down Expand Up @@ -1016,7 +1019,7 @@ function! GetPhpIndent()
" if optimized mode is active and nor current or previous line are an 'else'
" or the end of a possible bracketless thing then indent the same as the previous
" line
if last_line =~ '[;}]'.endline && last_line !~ '^)' && last_line !~# s:defaultORcase " Added && last_line !~ '^)' on 2007-12-30
if last_line =~ '[;}]'.endline && last_line !~ '^[)\]]' && last_line !~# s:defaultORcase
if ind==b:PHP_default_indenting
" if no indentation for the previous line
return b:PHP_default_indenting + addSpecial
Expand Down Expand Up @@ -1098,7 +1101,7 @@ function! GetPhpIndent()
"
" $thing =
" "something";
elseif (ind != b:PHP_default_indenting || last_line =~ '^)' ) && last_line =~ terminated " Added || last_line =~ '^)' on 2007-12-30 (array indenting problem broke other things)
elseif (ind != b:PHP_default_indenting || last_line =~ '^[)\]]' ) && last_line =~ terminated " Added || last_line =~ '^)' on 2007-12-30 (array indenting problem broke other things)
" If we are here it means that the previous line is:
" - a *;$ line
" - a [beginning-blanck] } followed by anything but a { $
Expand Down Expand Up @@ -1221,9 +1224,9 @@ function! GetPhpIndent()
" the last line isn't a .*; or a }$ line
" Indent correctly multilevel and multiline '(.*)' things

" if the last line is a [{(]$ or a multiline function call (or array
" if the last line is a [{(\[]$ or a multiline function call (or array
" declaration) with already one parameter on the opening ( line
if last_line =~# '[{(]'.endline || last_line =~? '\h\w*\s*(.*,$' && AntepenultimateLine !~ '[,(]'.endline
if last_line =~# '[{(\[]'.endline || last_line =~? '\h\w*\s*(.*,$' && AntepenultimateLine !~ '[,(]'.endline

if !b:PHP_BracesAtCodeLevel || last_line !~# '^\s*{'
let ind = ind + &sw
Expand Down Expand Up @@ -1279,7 +1282,7 @@ function! GetPhpIndent()
"echo "end"
"call getchar()
" If the current line closes a multiline function call or array def
if cline =~ '^\s*);\='
if cline =~ '^\s*[)\]];\='
let ind = ind - &sw
endif

Expand Down

0 comments on commit db30d6b

Please sign in to comment.