elixir.vim 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. if !exists('g:syntastic_enable_elixir_checker') || !g:syntastic_enable_elixir_checker
  27. call syntastic#log#error('checker elixir/elixir: checks disabled for security reasons; ' .
  28. \ 'set g:syntastic_enable_elixir_checker to 1 to override')
  29. return []
  30. endif
  31. let make_options = {}
  32. let compile_command = 'elixir'
  33. let mix_file = syntastic#util#findInParent('mix.exs', expand('%:p:h', 1))
  34. if filereadable(mix_file)
  35. let compile_command = 'mix compile'
  36. let make_options['cwd'] = fnamemodify(mix_file, ':p:h')
  37. endif
  38. let make_options['makeprg'] = self.makeprgBuild({ 'exe': compile_command })
  39. let make_options['errorformat'] =
  40. \ '%E** %*[^\ ] %f:%l: %m,' .
  41. \ '%W%f:%l: warning: %m'
  42. return SyntasticMake(make_options)
  43. endfunction
  44. call g:SyntasticRegistry.CreateAndRegisterChecker({
  45. \ 'filetype': 'elixir',
  46. \ 'name': 'elixir'})
  47. let &cpo = s:save_cpo
  48. unlet s:save_cpo
  49. " vim: set sw=4 sts=4 et fdm=marker: