phplint.vim 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. "============================================================================
  2. "File: phplint.vim
  3. "Description: Syntax checking plugin for syntastic.vim
  4. "Maintainer: LCD 47 <lcd047 at gmail dot com>
  5. "License: This program is free software. It comes without any warranty,
  6. " to the extent permitted by applicable law. You can redistribute
  7. " it and/or modify it under the terms of the Do What The Fuck You
  8. " Want To Public License, Version 2, as published by Sam Hocevar.
  9. " See http://sam.zoy.org/wtfpl/COPYING for more details.
  10. "
  11. "============================================================================
  12. if exists('g:loaded_syntastic_php_phplint_checker')
  13. finish
  14. endif
  15. let g:loaded_syntastic_php_phplint_checker = 1
  16. let s:save_cpo = &cpo
  17. set cpo&vim
  18. function! SyntaxCheckers_php_phplint_GetHighlightRegex(item)
  19. let term = matchstr(a:item['text'], '\munresolved function \zs\S\+\ze')
  20. if term !=# ''
  21. return '\V' . escape(term, '\')
  22. endif
  23. let term = matchstr(a:item['text'], '\m\(class\|function\|method\) \zs\S\+\ze was declared as')
  24. if term !=# ''
  25. return '\V' . escape(term, '\')
  26. endif
  27. let term = matchstr(a:item['text'], '\maccess forbidden to \(private\|protected\) \(class\|constant\|method\|variable\|\(private\|protected\) property\) \zs\S\+\ze')
  28. if term !=# ''
  29. return '\V' . escape(term, '\')
  30. endif
  31. let term = matchstr(a:item['text'], '\musing deprecated \(class\|constant\|method\|property\|variable\) \zs\S\+\ze')
  32. if term !=# ''
  33. return '\V' . escape(term, '\')
  34. endif
  35. let term = matchstr(a:item['text'], '\munresolved function \zs\S\+\ze')
  36. if term !=# ''
  37. return '\V' . escape(term, '\')
  38. endif
  39. let term = matchstr(a:item['text'], '\munresolved function \zs\S\+\ze')
  40. if term !=# ''
  41. return '\V' . escape(term, '\')
  42. endif
  43. let term = matchstr(a:item['text'], '\munresolved function \zs\S\+\ze')
  44. return term !=# '' ? '\V' . escape(term, '\') : ''
  45. endfunction
  46. function! SyntaxCheckers_php_phplint_GetLocList() dict
  47. let makeprg = self.makeprgBuild({
  48. \ 'args_after':
  49. \ '--print-file-name ' .
  50. \ '--print-line-numbers ' .
  51. \ '--print-column-number ' .
  52. \ '--print-errors ' .
  53. \ '--print-warnings ' .
  54. \ '--no-print-notices ' .
  55. \ '--no-print-context ' .
  56. \ '--no-print-source ' .
  57. \ '--tab-size ' . &tabstop })
  58. let errorformat =
  59. \ '%E%f:%l:%v: %tRROR: %m,' .
  60. \ '%W%f:%l:%v: %tarning: %m,' .
  61. \ '%+C%\t%.%#,' .
  62. \ '%-G%.%#'
  63. let loclist = SyntasticMake({
  64. \ 'makeprg': makeprg,
  65. \ 'errorformat': errorformat,
  66. \ 'postprocess': ['compressWhitespace'],
  67. \ 'subtype': 'Style',
  68. \ 'returns': [0, 1] })
  69. for e in loclist
  70. let e['text'] = substitute(e['text'], '\m \(Hint\|Examples\):.*', '', '')
  71. endfor
  72. return loclist
  73. endfunction
  74. call g:SyntasticRegistry.CreateAndRegisterChecker({
  75. \ 'filetype': 'php',
  76. \ 'name': 'phplint',
  77. \ 'exec': 'phpl' })
  78. let &cpo = s:save_cpo
  79. unlet s:save_cpo
  80. " vim: set sw=4 sts=4 et fdm=marker: