escript.vim 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. "============================================================================
  2. "File: erlang.vim
  3. "Description: Syntax checking plugin for syntastic.vim
  4. "Maintainer: Pawel Salata <rockplayer.pl 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_erlang_erlang_checker')
  13. finish
  14. endif
  15. let g:loaded_syntastic_erlang_erlang_checker = 1
  16. if !exists('g:syntastic_erlc_include_path')
  17. let g:syntastic_erlc_include_path = ''
  18. endif
  19. let s:check_file = syntastic#util#shescape(expand('<sfile>:p:h', 1) . syntastic#util#Slash() . 'erlang_check_file.erl')
  20. let s:save_cpo = &cpo
  21. set cpo&vim
  22. function! SyntaxCheckers_erlang_escript_GetLocList() dict
  23. if expand('%:e', 1) ==# 'hrl'
  24. return []
  25. endif
  26. let shebang = syntastic#util#parseShebang()
  27. if shebang['exe'] ==# 'escript'
  28. let args = '-s'
  29. let post_args = ''
  30. else
  31. let args = s:check_file
  32. let post_args = g:syntastic_erlc_include_path
  33. endif
  34. let makeprg = self.makeprgBuild({
  35. \ 'args_after': args,
  36. \ 'fname': syntastic#util#shexpand('%:p'),
  37. \ 'post_args_after': post_args })
  38. let errorformat =
  39. \ '%W%f:%l: warning: %m,'.
  40. \ '%E%f:%l: %m'
  41. return SyntasticMake({
  42. \ 'makeprg': makeprg,
  43. \ 'errorformat': errorformat })
  44. endfunction
  45. call g:SyntasticRegistry.CreateAndRegisterChecker({
  46. \ 'filetype': 'erlang',
  47. \ 'name': 'escript'})
  48. let &cpo = s:save_cpo
  49. unlet s:save_cpo
  50. " vim: set sw=4 sts=4 et fdm=marker: