flow.vim 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. "============================================================================
  2. "File: flow.vim
  3. "Description: Javascript syntax checker - using flow
  4. "Maintainer: Michael Robinson <mike@pagesofinterest.net>
  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. if exists('g:loaded_syntastic_javascript_flow_checker')
  12. finish
  13. endif
  14. let g:loaded_syntastic_javascript_flow_checker = 1
  15. if !exists('g:syntastic_javascript_flow_sort')
  16. let g:syntastic_javascript_flow_sort = 1
  17. endif
  18. let s:save_cpo = &cpo
  19. set cpo&vim
  20. function! SyntaxCheckers_javascript_flow_IsAvailable() dict
  21. if !executable(self.getExec())
  22. return 0
  23. endif
  24. return syntastic#util#versionIsAtLeast(self.getVersion(self.getExecEscaped() . ' version'), [0, 34])
  25. endfunction
  26. function! SyntaxCheckers_javascript_flow_GetLocList() dict
  27. let buf = bufnr('')
  28. if syntastic#util#findFileInParent('.flowconfig', fnamemodify(bufname(buf), ':p:h')) ==# ''
  29. return []
  30. endif
  31. let makeprg = self.makeprgBuild({
  32. \ 'exe': self.getExecEscaped() . ' status',
  33. \ 'args_after': '--quiet --show-all-errors --json' })
  34. let errorformat =
  35. \ '%f:%l:%c:%n: %m,' .
  36. \ '%f:%l:%c: %m'
  37. let loclist = SyntasticMake({
  38. \ 'makeprg': makeprg,
  39. \ 'errorformat': errorformat,
  40. \ 'preprocess': 'flow',
  41. \ 'defaults': {'type': 'E'} })
  42. for e in loclist
  43. if get(e, 'col', 0) && get(e, 'nr', 0)
  44. let e['hl'] = '\%>' . (e['col'] - 1) . 'c\%<' . (e['nr'] + 1) . 'c'
  45. let e['nr'] = 0
  46. endif
  47. endfor
  48. return loclist
  49. endfunction
  50. call g:SyntasticRegistry.CreateAndRegisterChecker({
  51. \ 'filetype': 'javascript',
  52. \ 'name': 'flow'})
  53. let &cpo = s:save_cpo
  54. unlet s:save_cpo
  55. " vim: set sw=4 sts=4 et fdm=marker: