elixir.vim 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. "============================================================================
  2. "File: elixir.vim
  3. "Description: Syntax checking plugin for syntastic
  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 buf = bufnr('')
  27. let make_options = {}
  28. let compile_command = 'elixir'
  29. let mix_file = syntastic#util#findFileInParent('mix.exs', fnamemodify(bufname(buf), ':p:h'))
  30. if filereadable(mix_file)
  31. let compile_command = 'mix compile'
  32. let make_options['cwd'] = fnamemodify(mix_file, ':p:h')
  33. endif
  34. let make_options['makeprg'] = self.makeprgBuild({ 'exe': compile_command })
  35. let make_options['errorformat'] =
  36. \ '%E** %*[^\ ] %f:%l: %m,' .
  37. \ '%W%f:%l: warning: %m'
  38. return SyntasticMake(make_options)
  39. endfunction
  40. call g:SyntasticRegistry.CreateAndRegisterChecker({
  41. \ 'filetype': 'elixir',
  42. \ 'name': 'elixir',
  43. \ 'enable': 'enable_elixir_checker'})
  44. let &cpo = s:save_cpo
  45. unlet s:save_cpo
  46. " vim: set sw=4 sts=4 et fdm=marker: