Skip to content

Commit

Permalink
reindent
Browse files Browse the repository at this point in the history
  • Loading branch information
arnaud-lb committed Apr 6, 2011
1 parent 17bab33 commit e5eef43
Showing 1 changed file with 56 additions and 56 deletions.
112 changes: 56 additions & 56 deletions runtime/plugin/phpns.vim
Original file line number Diff line number Diff line change
Expand Up @@ -7,64 +7,64 @@
" This is an adaptation of a script found at http://vim.wikia.com/wiki/Add_Java_import_statements_automatically

function! PhpInsertUse()
exe "normal mz"
" move to the first component
" Foo\Bar => move to the F
call search('[[:alnum:]\\]\+', 'bcW')
let cur_class = expand("<cword>")
try
" this matches
" - use Foo\<cur_class>
" - use Foo\Bar as <cur_class>
if search('^\s*use\_s\+\_[^;]*\%(\\\|\_s\)' . cur_class . '\_s*[;,]') > 0
echo "import for " . cur_class . " already exist"
exe "normal! `z"
return
endif
exe "ptjump " . cur_class
exe "normal mz"
" move to the first component
" Foo\Bar => move to the F
call search('[[:alnum:]\\]\+', 'bcW')
let cur_class = expand("<cword>")
try
wincmd P
" this matches
" - use Foo\<cur_class>
" - use Foo\Bar as <cur_class>
if search('^\s*use\_s\+\_[^;]*\%(\\\|\_s\)' . cur_class . '\_s*[;,]') > 0
echo "import for " . cur_class . " already exist"
exe "normal! `z"
return
endif
exe "ptjump " . cur_class
try
wincmd P
catch /.*/
return
endtry
1
if search('^\s*\%(abstract\_s\+\)\?\%(class\|interface\)\_s\+' . cur_class . '\>') > 0
if search('^\s*namespace\s\+', 'b') > 0
yank y
else
throw "Namespace definition not found!"
endif
else
throw cur_class . ": class not found!"
endif
wincmd p
normal! G
" insert after last use or namespace or <?php
if search('^\s*use\_s\_[^;]*;', 'be') > 0
put y
elseif search('^\s*namespace\_s\_[^;{]*[;{]', 'be') > 0
exe "normal! jO\<Esc>"
put y
elseif search('<?\%(php\)\?', 'be') > 0
exe "normal! jO\<Esc>"
put y
else
1
put y
endif
substitute/^\s*namespace/use/g
substitute/\s\+/ /g
substitute/\s*[{;]\?\s*$/;/
exe "normal! 2ER\\" . cur_class . ";\<Esc>lD"
catch /.*/
return
echoerr v:exception
finally
" wipe preview window (from buffer list)
silent! wincmd P
if &previewwindow
bwipeout
endif
exe "normal! `z"
endtry
1
if search('^\s*\%(abstract\_s\+\)\?\%(class\|interface\)\_s\+' . cur_class . '\>') > 0
if search('^\s*namespace\s\+', 'b') > 0
yank y
else
throw "Namespace definition not found!"
endif
else
throw cur_class . ": class not found!"
endif
wincmd p
normal! G
" insert after last use or namespace or <?php
if search('^\s*use\_s\_[^;]*;', 'be') > 0
put y
elseif search('^\s*namespace\_s\_[^;{]*[;{]', 'be') > 0
exe "normal! jO\<Esc>"
put y
elseif search('<?\%(php\)\?', 'be') > 0
exe "normal! jO\<Esc>"
put y
else
1
put y
endif
substitute/^\s*namespace/use/g
substitute/\s\+/ /g
substitute/\s*[{;]\?\s*$/;/
exe "normal! 2ER\\" . cur_class . ";\<Esc>lD"
catch /.*/
echoerr v:exception
finally
" wipe preview window (from buffer list)
silent! wincmd P
if &previewwindow
bwipeout
endif
exe "normal! `z"
endtry
endfunction

0 comments on commit e5eef43

Please sign in to comment.