php.vim 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. " Vim filetype plugin file
  2. " Language: php
  3. "
  4. " This runtime file is looking for a new maintainer.
  5. "
  6. " Former maintainer: Dan Sharp
  7. " Last Changed: 20 Jan 2009
  8. if exists("b:did_ftplugin") | finish | endif
  9. " Make sure the continuation lines below do not cause problems in
  10. " compatibility mode.
  11. let s:keepcpo= &cpo
  12. set cpo&vim
  13. " Define some defaults in case the included ftplugins don't set them.
  14. let s:undo_ftplugin = ""
  15. let s:browsefilter = "HTML Files (*.html, *.htm)\t*.html;*.htm\n" .
  16. \ "All Files (*.*)\t*.*\n"
  17. let s:match_words = ""
  18. runtime! ftplugin/html.vim ftplugin/html_*.vim ftplugin/html/*.vim
  19. let b:did_ftplugin = 1
  20. " Override our defaults if these were set by an included ftplugin.
  21. if exists("b:undo_ftplugin")
  22. let s:undo_ftplugin = b:undo_ftplugin
  23. endif
  24. if exists("b:browsefilter")
  25. let s:browsefilter = b:browsefilter
  26. endif
  27. if exists("b:match_words")
  28. let s:match_words = b:match_words
  29. endif
  30. if exists("b:match_skip")
  31. unlet b:match_skip
  32. endif
  33. " Change the :browse e filter to primarily show PHP-related files.
  34. if has("gui_win32")
  35. let b:browsefilter="PHP Files (*.php)\t*.php\n" . s:browsefilter
  36. endif
  37. " ###
  38. " Provided by Mikolaj Machowski <mikmach at wp dot pl>
  39. setlocal include=\\\(require\\\|include\\\)\\\(_once\\\)\\\?
  40. " Disabled changing 'iskeyword', it breaks a command such as "*"
  41. " setlocal iskeyword+=$
  42. if exists("loaded_matchit")
  43. let b:match_words = '<?php:?>,\<switch\>:\<endswitch\>,' .
  44. \ '\<if\>:\<elseif\>:\<else\>:\<endif\>,' .
  45. \ '\<while\>:\<endwhile\>,' .
  46. \ '\<do\>:\<while\>,' .
  47. \ '\<for\>:\<endfor\>,' .
  48. \ '\<foreach\>:\<endforeach\>,' .
  49. \ '(:),[:],{:},' .
  50. \ s:match_words
  51. endif
  52. " ###
  53. if exists('&omnifunc')
  54. setlocal omnifunc=phpcomplete#CompletePHP
  55. endif
  56. " Section jumping: [[ and ]] provided by Antony Scriven <adscriven at gmail dot com>
  57. let s:function = '\(abstract\s\+\|final\s\+\|private\s\+\|protected\s\+\|public\s\+\|static\s\+\)*function'
  58. let s:class = '\(abstract\s\+\|final\s\+\)*class'
  59. let s:interface = 'interface'
  60. let s:section = '\(.*\%#\)\@!\_^\s*\zs\('.s:function.'\|'.s:class.'\|'.s:interface.'\)'
  61. exe 'nno <buffer> <silent> [[ ?' . escape(s:section, '|') . '?<CR>:nohls<CR>'
  62. exe 'nno <buffer> <silent> ]] /' . escape(s:section, '|') . '/<CR>:nohls<CR>'
  63. exe 'ono <buffer> <silent> [[ ?' . escape(s:section, '|') . '?<CR>:nohls<CR>'
  64. exe 'ono <buffer> <silent> ]] /' . escape(s:section, '|') . '/<CR>:nohls<CR>'
  65. setlocal suffixesadd=.php
  66. setlocal commentstring=/*%s*/
  67. " Undo the stuff we changed.
  68. let b:undo_ftplugin = "setlocal suffixesadd< commentstring< include< omnifunc<" .
  69. \ " | unlet! b:browsefilter b:match_words | " .
  70. \ s:undo_ftplugin
  71. " Restore the saved compatibility options.
  72. let &cpo = s:keepcpo
  73. unlet s:keepcpo