php.vim 2.7 KB

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