Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Changed line break format to LF #1

Merged
merged 4 commits into from

4 participants

@matsubo
  • Updated line break format to LF.
  • Updated README file to markup mark down.
and others added some commits
@rayburgemeestre Version 1.8
Thanks to Dmitri Perunov for informing me of the fixes pending on github!
1. Fix for folding private, public, protected class variables + multi-line param by Jess Telford
2. Fix to make it work well as ftplugin (default now), added option for folding classes (disabled by default) and fix for fatal behavior, all by pekepeke
a5adf8b
Yuki Matsukura changed line break to lf 1e91941
@matsubo matsubo Update README 4c44668
Yuki Matsukura Updated readme 864c800
@t0nedef

Has this been tested with vim >=7.3 ?
I get warning messages when using version 1.8:

Error detected while processing /usr/share/vim/vim73/plugin/phpfolding.vim:
line 57:
E15: Invalid expression: &cpo^M
line 58:
E488: Trailing characters: cpo&vim^M
line 59:
E492: Not an editor command: ^M
line 61:
E15: Invalid expression: exists('loaded_phpfolding')^M
line 68:
E488: Trailing characters
line 632:
E488: Trailing characters
line 634:
E171: Missing :endif
Press ENTER or type command to continue

Has this been tested with vim >=7.3 ?
I get warning messages when using version 1.8:

Yes, I've tested 7.3 and 7.4.

The error message seems wrong line mode.
I correct it in this pull request.

@rayburgemeestre rayburgemeestre merged commit 864c800 into rayburgemeestre:master
@rayburgemeestre

Thanks, merged it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 28, 2013
  1. @vim-scripts

    Version 1.8

    authored vim-scripts committed
    Thanks to Dmitri Perunov for informing me of the fixes pending on github!
    1. Fix for folding private, public, protected class variables + multi-line param by Jess Telford
    2. Fix to make it work well as ftplugin (default now), added option for folding classes (disabled by default) and fix for fatal behavior, all by pekepeke
Commits on Oct 2, 2013
  1. changed line break to lf

    Yuki Matsukura authored
Commits on Oct 21, 2013
  1. @matsubo

    Update README

    matsubo authored
  2. Updated readme

    Yuki Matsukura authored
This page is out of date. Refresh to see the latest.
Showing with 150 additions and 109 deletions.
  1. +0 −65 README
  2. +84 −0 README.md
  3. +66 −44 plugin/phpfolding.vim
View
65 README
@@ -1,65 +0,0 @@
-This is a mirror of http://www.vim.org/scripts/script.php?script_id=1623
-
-This script can fold PHP functions and/or classes, properties with their PhpDoc,
-without manually adding marker style folds ({{{ and }}}). It will generate the following
-folds when executed:
-
-<?php
-/**
-* This is Foo...
-* @author Foo
-*/
-class Foo {
-+-- 11 lines: function fooFunction($bar) ** -----------------------------------------
-+-- 8 lines: function fooFunction2($bar) ** ----------------------------------------
-+-- 24 lines: function fooFunction3($bar) -------------------------------------------
-}
-
-+--112 lines: class Foo2 ** -------------------------------------------------------------
-?>
-
-Based on e.g. functions declared like this:
-
-<?php
-/**
- * This is fooFunction...
- *
- * @param mixed $bar
- * @access public
- * @return void
- */
-function fooFunction($bar) {
- [...]
-}
-?>
-
-SCREENSHOT
-You can view a screenshot here: http://www.fighterz.net/trig/folding.gif
-
-FEATURES
-- It remembers fold settings. If you add functions and execute the script again,
- your opened folds will not be closed.
-- It will not be confused by brackets in comment blocks or string literals.
-- The folding of class properties with their PhpDoc comments.
-- The folding of all class properties into one fold.
-- Folding the original marker style folds too.
-- An "**" postfixing the fold indicates PhpDoc is inside (configurable).
-- An "**#@+" postfixing the fold indicates PhpDocBlock is inside (configurable).
-- Empty lines postfixing the folds can be configured to be included in the fold.
-- Nested folds are supported (functions inside functions, etc.)
-
-FUTURE
-- Better 'configurability' as opposed to editting the PHPCustomFolds() function and
- some "Script configuration" global variables.
-
-NOTE
-If anyone has emailed me and I have not replied, it's probably lost. I just found out
-hotmail recognizes alot as junk. I now turned off the junk filter..
-
-NOTE2:
-I'm currently more active again with this project, so if you have any contributions to
-this project, please let me know.
-
-COMPATIBILITY
-This script is tested successfully with Vim version >= 6.3 on windows and linux
-(With 6.0 it works *sometimes*, I don't recommend using it in that version)
View
84 README.md
@@ -0,0 +1,84 @@
+Abstract
+===============
+
+This is a mirror of http://www.vim.org/scripts/script.php?script_id=1623
+
+This script can fold PHP functions and/or classes, properties with their phpdoc
+without manually adding marker style folds ({{{ and }}}).
+It will generate the following folds when executed:
+
+```
+<?php
+/**
+ * This is Foo...
+ * @author Foo
+ */
+class Foo
+{
++-- 11 lines: function foo($bar) ** -------------------------------------------------
++-- 8 lines: function bar($bar) ** -------------------------------------------------
++-- 24 lines: function baz($bar) ----------------------------------------------------
+}
+?>
+```
+
+Based on e.g. functions declared like this:
+
+```
+<?php
+/**
+* This is fooFunction...
+*
+* @param mixed $bar
+* @access public
+* @return void
+*/
+function fooFunction($bar)
+{
+ ...
+}
+?>
+```
+
+SCREENSHOT
+----------------
+You can view a screenshot here: http://blog.cppse.nl/phpfolding-vim
+
+FEATURES
+----------------
+- It remembers fold settings. If you add functions and execute the script again,
+ your opened folds will not be closed.
+- It will not be confused by brackets in comment blocks or string literals.
+- The folding of class properties with their PhpDoc comments.
+- The folding of all class properties into one fold.
+- Folding the original marker style folds too.
+- An "**" postfixing the fold indicates PhpDoc is inside (configurable).
+- An "**#@+" postfixing the fold indicates PhpDocBlock is inside (configurable).
+- Empty lines postfixing the folds can be configured to be included in the fold.
+- Nested folds are supported (functions inside functions, etc.)
+- Folding private, public, protected class variables + multi-line param.
+- Foloding the class is now an option disabled by default.
+- Now works properly as ftplugin
+
+FUTURE
+----------------
+- Better 'configurability' as opposed to editting the PHPCustomFolds() function
+ and some "Script configuration" global variables.
+
+CONTRIBUTE / GITHUB
+----------------
+- This project is hosted on github as a mirror through
+ - https://github.com/vim-scripts/phpfolding.vim
+- I do not own vim-scripts, so please fork mine instead:
+ - https://github.com/rayburgemeestre/phpfolding.vim
+
+It's then easier for me to accept pull requests and upload new version(s) here,
+also I cannot put phpfolding.vim in the ftplugin/php directory through the
+vim.org interface.
+
+
+COMPATIBILITY
+--------------
+
+This script is tested successfully with Vim version >= 6.3 on windows and linux
+(With 6.0 it works *sometimes*, I don't recommend using it in that version)
View
110 plugin/phpfolding.vim
@@ -1,7 +1,7 @@
" Plugin for automatic folding of PHP functions (also folds related PHPdoc)
"
" Maintainer: Ray Burgemeestre
-" Last Change: 2010 Jan 15
+" Last Change: 2013 Aug 26
"
" USAGE
" If you enabled the script in your after/ftplugin directory (see install)
@@ -17,7 +17,10 @@
" F7 - To remove all folds.
"
" INSTALL
-" 1. Put phpfolding.vim in your plugin directory (~/.vim/plugin)
+" 1. Put phpfolding.vim in your plugin directory (~/.vim/ftplugin/php/)
+"
+" make sure you have "filetype plugin on" in your .vimrc!
+"
" 2. You might want to add the following keyboard mappings to your .vimrc:
"
" map <F5> <Esc>:EnableFastPHPFolds<Cr>
@@ -28,9 +31,9 @@
"
" let g:DisableAutoPHPFolding = 1
"
-" By default EnableFastPHPFolds is called. Do these mess up your folds,
+" By default EnableFastPHPFolds is called. Do these mess up your folds,
" you can try to replace EnableFastPHPFolds by EnablePHPFolds. You can
-" change this in function s:CheckAutocmdEnablePHPFold.
+" change this in function s:CheckAutocmdEnablePHPFold.
"
" NOTE
" It may be that you need to load the plugin from your .vimrc manually, in
@@ -51,9 +54,18 @@
" at the "Script configuration" part.
"
" This script is tested with Vim version >= 6.3 on windows and linux.
+let s:save_cpo = &cpo
+set cpo&vim
" Avoid reloading {{{1
if exists('loaded_phpfolding')
+ " ftplugin section
+ if !get(g:, 'DisableAutoPHPFolding', 0)
+ call s:EnableFastPHPFolds()
+ endif
+
+ let &cpo = s:save_cpo
+ unlet s:save_cpo
finish
endif
@@ -64,6 +76,7 @@ let loaded_phpfolding = 1
if !exists("g:DisableAutoPHPFolding")
let g:DisableAutoPHPFolding = 0
endif
+let g:DisablePHPFoldingClass = get(g:, 'DisablePHPFoldingClass', 1)
" }}}
command! EnableFastPHPFolds call <SID>EnableFastPHPFolds()
@@ -109,8 +122,8 @@ function! s:EnablePHPFolds(...) " {{{
let s:savedCursor = line(".")
" Initialize variables
- set foldmethod=manual
- set foldtext=PHPFoldText()
+ setlocal foldmethod=manual
+ setlocal foldtext=PHPFoldText()
let s:openFoldListItems = 0
let s:fileLineCount = line('$')
@@ -119,8 +132,8 @@ function! s:EnablePHPFolds(...) " {{{
" Move to end of file
- exec s:fileLineCount
-
+ exec s:fileLineCount
+
" First pass: Look for Folds, remember opened folds
let s:foldingMode = s:MODE_REMEMBER_FOLD_SETTINGS
call s:PHPCustomFolds()
@@ -128,17 +141,17 @@ function! s:EnablePHPFolds(...) " {{{
" Second pass: Recreate Folds, restore previously opened
let s:foldingMode = s:MODE_CREATE_FOLDS
" .. Remove all folds first
- normal zE
+ normal! zE
let s:foldsCreated = 0
call s:PHPCustomFolds()
" .. Fold all
- normal zM
+ normal! zM
" Restore previously opened folds
let currentItem = 0
while currentItem < s:openFoldListItems
exec s:foldsOpenedList{currentItem}
- normal zo
+ normal! zo
let currentItem = currentItem + 1
endwhile
@@ -147,13 +160,13 @@ function! s:EnablePHPFolds(...) " {{{
" Restore cursor
exec s:savedCursor
-
+
endfunction
" }}}
function! s:DisablePHPFolds() " {{{
- "set foldmethod=manual
- set foldtext=
- normal zE
+ "setlocal foldmethod=manual
+ setlocal foldtext=
+ normal! zE
echo "php fold(s) deleted"
endfunction
" }}}
@@ -166,11 +179,13 @@ function! s:PHPCustomFolds() " {{{
call s:PHPFoldPureBlock('function', s:FOLD_WITH_PHPDOC)
" Fold class properties with PhpDoc (var $foo = NULL;)
- call s:PHPFoldProperties('^\s*var\s\$', ";", s:FOLD_WITH_PHPDOC, 1, 1)
+ call s:PHPFoldProperties('^\s*\(\(private\)\|\(public\)\|\(protected\)\|\(var\)\)\s\$', ";", s:FOLD_WITH_PHPDOC, 1, 1)
+
+ if !g:DisablePHPFoldingClass
+ " Fold class without PhpDoc (class foo {})
+ call s:PHPFoldPureBlock('^\s*\(abstract\s*\)\?class', s:FOLD_WITH_PHPDOC)
+ endif
- " Fold class without PhpDoc (class foo {})
- call s:PHPFoldPureBlock('^\s*\(abstract\s*\)\?class', s:FOLD_WITH_PHPDOC)
-
" Fold define()'s with their PhpDoc
call s:PHPFoldProperties('^\s*define\s*(', ";", s:FOLD_WITH_PHPDOC)
@@ -237,7 +252,7 @@ function! s:PHPFoldPureBlock(startPattern, ...) " {{{
if s:foldingMode != s:MODE_REMEMBER_FOLD_SETTINGS
" Remove created folds
- normal zR
+ normal! zR
endif
endfunction
" }}}
@@ -275,7 +290,7 @@ function! s:PHPFoldMarkers(startPattern, endPattern, ...) " {{{
if s:foldingMode != s:MODE_REMEMBER_FOLD_SETTINGS
" Remove created folds
- normal zR
+ normal! zR
endif
endfunction
" }}}
@@ -320,12 +335,12 @@ function! s:PHPFoldProperties(startPattern, endPattern, ...) " {{{
" Goto fold start (remember we're searching upwards)
exec s:lineStart
-
+
endwhile
if s:foldingMode != s:MODE_REMEMBER_FOLD_SETTINGS
" Remove created folds
- normal zR
+ normal! zR
endif
endfunction
" }}}
@@ -351,7 +366,7 @@ function! s:HandleFold() " {{{
let s:foldsOpenedList{s:openFoldListItems} = s:lineStart
let s:openFoldListItems = s:openFoldListItems + 1
endif
-
+
elseif s:foldingMode == s:MODE_CREATE_FOLDS
" Correct lineStop if needed (the script might have mistaken lines
" beyond the file's scope for trailing empty lines)
@@ -380,9 +395,9 @@ function! s:FindPureBlockStart(startPattern) " {{{
" This function can match the line its on *again* if the cursor was
" restored.. hence we search twice if needed..
let currentLine = line('.')
- let line = search(a:startPattern . '.*\%[\n].*\%[\n].*{', 'bW')
+ let line = search(a:startPattern . '.*\(\%[\n].*\)\{,10\}{', 'bW')
if currentLine == line
- let line = search(a:startPattern . '.*\%[\n].*\%[\n].*{', 'bW')
+ let line = search(a:startPattern . '.*\(\%[\n].*\)\{,10\}{', 'bW')
endif
return line
endfunction
@@ -478,7 +493,7 @@ function! s:FindPureBlockEnd(startPair, endPair, searchStartPairFirst, ...) " {{
" Then be greedy with extra 'trailing' empty line(s)
let s:counter = 0
while s:counter < s:searchEmptyLinesPostfixing
- let linestr = getline(line + 1)
+ let linestr = getline(line + 1)
if (matchstr(linestr, '^\s*$') == linestr)
let line = line + 1
endif
@@ -497,7 +512,7 @@ function! s:FindPatternEnd(endPattern) " {{{
" Then be greedy with extra 'trailing' empty line(s)
let s:counter = 0
while s:counter < s:searchEmptyLinesPostfixing
- let linestr = getline(line + 1)
+ let linestr = getline(line + 1)
if (matchstr(linestr, '^\s*$') == linestr)
let line = line + 1
endif
@@ -553,7 +568,7 @@ function! PHPFoldText() " {{{
endwhile
let lineString = getline(currentLine)
endif
-
+
" Some common replaces...
" if currentLine != v:foldend
let lineString = substitute(lineString, '/\*\|\*/\d\=', '', 'g')
@@ -572,7 +587,7 @@ function! PHPFoldText() " {{{
" Append an (a) if there is PhpDoc in the fold (a for API)
if currentLine != v:foldstart
let lineString = lineString . " " . g:phpDocIncludedPostfix . " "
- endif
+ endif
" Return the foldtext
return "+--".lines." lines: " . lineString
@@ -593,19 +608,26 @@ function! SkipMatch() " {{{
endfun
" }}}
-" Check filetype == php before automatically creating (fast) folds {{{1
-function! s:CheckAutocmdEnablePHPFold()
- if &filetype == "php" && ! g:DisableAutoPHPFolding
- call s:EnableFastPHPFolds()
- endif
-endfunction
-" }}}
-
-" Call CheckAutocmdEnablePHPFold on BufReadPost {{{1
-augroup SetPhpFolds
- au!
- au BufReadPost * call s:CheckAutocmdEnablePHPFold()
-augroup END
-" }}}
+" " Check filetype == php before automatically creating (fast) folds {{{1
+" function! s:CheckAutocmdEnablePHPFold()
+" if &filetype == "php" && ! g:DisableAutoPHPFolding
+" call s:EnableFastPHPFolds()
+" endif
+" endfunction
+" " }}}
+
+" " Call CheckAutocmdEnablePHPFold on BufReadPost {{{1
+" augroup SetPhpFolds
+" au!
+" au BufReadPost * call s:CheckAutocmdEnablePHPFold()
+" augroup END
+" " }}}
+
+" ftplugin section
+if !get(g:, 'DisableAutoPHPFolding', 0)
+ call s:EnableFastPHPFolds()
+endif
+let &cpo = s:save_cpo
+unlet s:save_cpo
" vim:ft=vim:foldmethod=marker:nowrap:tabstop=4:shiftwidth=4
Something went wrong with that request. Please try again.