321db406af64aa55717cfd04e65983b6b32b40f8
Author: AD7six
Date: 2009-11-20 00:28:22 +0100
diff --git a/vendors/vim/indent/php.vim b/vendors/vim/indent/php.vim
new file mode 100644
index 0000000..368760f
--- /dev/null
+++ b/vendors/vim/indent/php.vim
@@ -0,0 +1,7 @@
+"
+" Disable inbuilt php indentation
+let b:did_indent = 1
+set cindent
+set indentexpr=
+set cindent cino=(0,W4,m1
+set ts=1 noet
\ No newline at end of file
diff --git a/vendors/vim/plugins/cakephp.vim b/vendors/vim/plugins/cakephp.vim
index 6fb0f80..ad37e53 100644
--- a/vendors/vim/plugins/cakephp.vim
+++ b/vendors/vim/plugins/cakephp.vim
@@ -18,7 +18,7 @@
" :V - Open the view file
" :C - Open the controller file
" :D - Add doc blocks to the current buffer
-" :F - Clean the current buffer
+" :F - Clean the current buffer (Apply code standards)
" :R - Regenerate all docs for the current file
" :L - Show the log
@@ -152,16 +152,6 @@ function s:DocPaste(start)
endif
endfunc
-" Function: IndentComments()
-" C default doc blocks are indented the same as the function they document (I deduce)
-" This function will remove leading whitespace from doc blocks in keeping with CakePHP standards
-function s:IndentComments()
- " correct doc block headers that are indented ( /**)
- exe "norm :%s/^\\s*\\/\\*\\*/\\/\\*\\*/e\<CR>"
- " correct doc block contents/tail that is indented ( * or */)
- exe "norm :%s/^\\s*\\*/ \\*/e\<CR>"
-endfunction
-
" Function: BufferWritePre()
" EOL markers are not desired, change to binary mode before saving so one isn't added
function s:BufferWritePre()
@@ -248,16 +238,26 @@ function Cake(...)
endfor
endfunction
+" Function: ExplodePhp()
+" For code that's not wrapped correctly, explode it (put each new array element on a new line)
+" and then indent it. It's a lot easier to read/cleanup code that's been too-exploded
+" than code that isn't wrapped/formatted/indented
+function ExplodePhp() range
+ "explode on any comma, or ()
+ :silent '<,'>s/\([,()]\)\( \?[^, ]\)/\1 \r\2/ge
+ "for any closing bracket that isn't on its own line explode that too
+ :silent '<,'>s/\([\S]\))\(,?\)$/\1\r)\2/ge
+ "For a closing bracket, with a semicolon on the following line - clean up
+ :silent '<,'>s/)\s\r\s*;/);/e
+ "indent the range TODO not working
+ '<,'>=
+endfunction
+
" Function: FormatPhp()
" (Attempt to) autoformat php code according to various conventions
function FormatPhp() range
- " put a blank line before comment blocks
- :silent '<,'>s/\([\{\}\/;]\)\n\zs\/\*/\r\/\*/e
- " correct doc block headers
- :silent '<,'>s/^\s*\/\*\*/\/\*\*/e
- " correct doc block contents/tail that is indented ( * or */)
- :silent '<,'>s/^\s*\*/ \*/e
-
+ ""replace any double spaces with a single space
+ ":silent '<,'>s/ \{2,}/ /ge
"remove trailing whitespace
:silent '<,'>s/\s\s*$//e
@@ -278,7 +278,14 @@ function FormatPhp() range
:silent '<,'>s/\([^=<>& ]\)\([!<]\?==\?[=>&]\?\)/\1 \2/ge
" correct whitespace around assignments/comparisons x =y becomes x = y
:silent '<,'>s/\([!<]\?==\?[=>&]\?\)\([^=<>& ]\)/\1 \2/ge
- ":silent %s/=\([^=&> ]\)\@=/= /e
+
+ " put a blank line before comment blocks
+ :silent '<,'>s/\([\{\}\/;]\)\n\zs\/\*/\r\/\*/e
+ " correct doc block headers
+ :silent '<,'>s/^\s*\/\*\*/\/\*\*/e
+ " correct doc block contents/tail that is indented ( * or */)
+ :silent '<,'>s/^\s*\*/ \*/e
+ '<,'>:call s:FormatComments()
endfunction
" Function: Controller()
@@ -451,14 +458,6 @@ function DocTags(...)
endif
endfunction
-" Function: CleanBuffer()
-" Perform automatic corrections for various syntax errors.
-" Correct whitespace and indent comments
-function s:CleanBuffer()
- call s:CorrectWhitespace()
- call s:IndentComments()
-endfunc
-
" Function: SetupCommands()
" Setup default commands for each of the public methods
function s:SetupCommands()
@@ -474,9 +473,6 @@ function s:SetupCommands()
if !exists(":D")
command -nargs=0 D %call DocRange()
endif
- "if !exists(":F")
- " command -nargs=0 F %call s:CleanBuffer()
- "endif
if !exists(":R")
command -nargs=0 R %call FormatPhp()
endif
@@ -507,12 +503,10 @@ function s:SetupMappings()
" map <buffer> <unique> <Leader>r <Plug>DocRange
" map <buffer> <unique> <Leader>a %<Plug>DocRange
"endif
- "if !hasmapto('<Plug>CleanBuffer')
- " map <buffer> <unique> <Leader>f <Plug>CleanBuffer
- "endif
nnoremap <buffer> <C-F> :%call FormatPhp()<CR>
vnoremap <buffer> <C-F> :call FormatPhp()<CR>
- nnoremap <buffer> <C-G> :call <SID>CleanBuffer()<CR>
+ nnoremap <buffer> <C-X> :%call ExplodePhp()<CR>
+ vnoremap <buffer> <C-X> :call ExplodePhp()<CR>
inoremap <buffer> <C-P> <Esc>:call DocSingle()<CR>i
nnoremap <buffer> <C-P> :call DocSingle()<CR>
vnoremap <buffer> <C-P> :call DocRange()<CR>
@@ -528,7 +522,6 @@ function s:SetupMenu()
noremenu <script> &Plugin.&CakePHP.Switch\ To\ &Model<Tab>:M :call Model()<CR>
noremenu <script> &Plugin.&CakePHP.Switch\ To\ &View<Tab>:V :call View()<CR>
noremenu <script> &Plugin.&CakePHP.Switch\ To\ &Controller<Tab>:C :call Controller()<CR>
- noremenu <script> &Plugin.&CakePHP.Clean\ &Up<Tab>:F :call <SID>CleanBuffer()<CR>
inoremenu <script> &Plugin.&CakePHP.Add\ &Doc\ Block<Tab>:D <Esc>:call DocSingle()<CR>i
nnoremenu <script> &Plugin.&CakePHP.Add\ &Doc\ Block<Tab>:D :call DocSingle()<CR>
@@ -553,44 +546,20 @@ endfunction
" Function: FormatComments()
" Correct whitespace around doc blocks
-function s:FormatComments()
- " License correction
- %s/<http:\/\/www.cakephp.org\/>/(http:\/\/www.cakephp.org)/ge
- %s/Copyright 2005-2008, Cake Software Foundation, Inc.\s*$/Copyright 2005-2008, Cake Software Foundation, Inc. (http:\/\/www.cakefoundation.org)/ge
- silent g/1785 E. Sahara Avenue, Suite 490-204/d
- silent g/Las Vegas, Nevada 89104/d
- " License correction end
- %s/\*\s*@copyright\s*/\* @copyright /ge
- %s/\*\s*@link\s*/\* @link /ge
- %s/\*\s*@package\s*/\* @package /ge
- %s/\*\s*@subpackage\s*/\* @subpackage /ge
- %s/\*\s*@since\s*/\* @since /ge
- %s/\*\s*@version\s*/\* @version /ge
- %s/\*\s*@modifiedBy\s*/\* @modifiedby /ge
- %s/\*\s*@modifiedby\s*/\* @modifiedby /ge
- %s/\*\s*@lastModified\s*/\* @lastmodified /ge
- %s/\*\s*@lastmodified\s*/\* @lastmodified /ge
- %s/\*\s*@license\s*/\* @license /ge
- %s/\*\s*@uses\s*/\* @uses /ge
- %s/\*\s*@author\s*/\* @author /ge
- norm gg
-endfunction
-
-" Function: CorrectWhitespace()
-" TODO intended to change:
-" $x=$y->( $z,$a, $b) ;
-" into
-" $x = $y->($z, $a, $b);
-function s:CorrectWhitespace()
- " :%s/,\(\S\)\@=/, / " parameters
- let cmd = "norm :%s/,\\(\\S\\)\\@=/, /e\<CR>"
- let s:CommandLog = s:CommandLog + [cmd]
- exe cmd
-
- " :%s/=\([^=&> ]\)\@=/= / " = signs, trailing whitespace
- let cmd = "norm :%s/=\\([^=&> ]\\)\\@=/= /e\<CR>"
- let s:CommandLog = s:CommandLog + [cmd]
- exe cmd
+function s:FormatComments() range
+ '<,'>s/\*\s*@copyright\s*/\* @copyright /ge
+ '<,'>s/\*\s*@link\s*/\* @link /ge
+ '<,'>s/\*\s*@package\s*/\* @package /ge
+ '<,'>s/\*\s*@subpackage\s*/\* @subpackage /ge
+ '<,'>s/\*\s*@since\s*/\* @since /ge
+ '<,'>s/\*\s*@version\s*/\* @version /ge
+ '<,'>s/\*\s*@modifiedBy\s*/\* @modifiedby /ge
+ '<,'>s/\*\s*@modifiedby\s*/\* @modifiedby /ge
+ '<,'>s/\*\s*@lastModified\s*/\* @lastmodified /ge
+ '<,'>s/\*\s*@lastmodified\s*/\* @lastmodified /ge
+ '<,'>s/\*\s*@license\s*/\* @license /ge
+ '<,'>s/\*\s*@uses\s*/\* @uses /ge
+ '<,'>s/\*\s*@author\s*/\* @author /ge
endfunction
" Function: DeleteBlankLines()
