elixir.vim 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. "============================================================================
  2. "File: elixir.vim
  3. "Description: Syntax checking plugin for syntastic.vim
  4. "Maintainer: Richard Ramsden <rramsden 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_elixir_elixir_checker')
  13. finish
  14. endif
  15. let g:loaded_syntastic_elixir_elixir_checker = 1
  16. let s:save_cpo = &cpo
  17. set cpo&vim
  18. " TODO: we should probably split this into separate checkers
  19. function! SyntaxCheckers_elixir_elixir_IsAvailable() dict
  20. call self.log(
  21. \ 'executable("elixir") = ' . executable('elixir') . ', ' .
  22. \ 'executable("mix") = ' . executable('mix'))
  23. return executable('elixir') && executable('mix')
  24. endfunction
  25. function! SyntaxCheckers_elixir_elixir_GetLocList() dict
  26. let make_options = {}
  27. let compile_command = 'elixir'
  28. let mix_file = syntastic#util#findFileInParent('mix.exs', expand('%:p:h', 1))
  29. if filereadable(mix_file)
  30. let compile_command = 'mix compile'
  31. let make_options['cwd'] = fnamemodify(mix_file, ':p:h')
  32. endif
  33. let make_options['makeprg'] = self.makeprgBuild({ 'exe': compile_command })
  34. let make_options['errorformat'] =
  35. \ '%E** %*[^\ ] %f:%l: %m,' .
  36. \ '%W%f:%l: warning: %m'
  37. return SyntasticMake(make_options)
  38. endfunction
  39. call g:SyntasticRegistry.CreateAndRegisterChecker({
  40. \ 'filetype': 'elixir',
  41. \ 'name': 'elixir',
  42. \ 'enable': 'enable_elixir_checker'})
  43. let &cpo = s:save_cpo
  44. unlet s:save_cpo
  45. " vim: set sw=4 sts=4 et fdm=marker: