You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

php.vim 1.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. " Code originally from
  2. " http://vim.wikia.com/wiki/Better_indent_support_for_php_with_html
  3. " Better indent support for PHP by making it possible to indent HTML sections
  4. " as well.
  5. if exists("b:did_indent")
  6. finish
  7. endif
  8. " This script pulls in the default indent/php.vim with the :runtime command
  9. " which could re-run this script recursively unless we catch that:
  10. if exists('s:doing_indent_inits')
  11. finish
  12. endif
  13. let s:doing_indent_inits = 1
  14. runtime! indent/html.vim
  15. unlet b:did_indent
  16. runtime! indent/php.vim
  17. unlet s:doing_indent_inits
  18. function! GetPhpHtmlIndent(lnum)
  19. if exists('*HtmlIndent')
  20. let html_ind = HtmlIndent()
  21. else
  22. let html_ind = HtmlIndentGet(a:lnum)
  23. endif
  24. let php_ind = GetPhpIndent()
  25. " priority one for php indent script
  26. if php_ind > -1
  27. return php_ind
  28. endif
  29. if html_ind > -1
  30. if getline(a:num) =~ "^<?" && (0< searchpair('<?', '', '?>', 'nWb')
  31. \ || 0 < searchpair('<?', '', '?>', 'nW'))
  32. return -1
  33. endif
  34. return html_ind
  35. endif
  36. return -1
  37. endfunction
  38. setlocal indentexpr=GetPhpHtmlIndent(v:lnum)
  39. setlocal indentkeys+=<>>