lessc.vim 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. "============================================================================
  2. "File: less.vim
  3. "Description: Syntax checking plugin for syntastic.vim
  4. "Maintainer: Julien Blanchard <julien at sideburns dot eu>
  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_less_lessc_checker')
  13. finish
  14. endif
  15. let g:loaded_syntastic_less_lessc_checker = 1
  16. if !exists('g:syntastic_less_options')
  17. let g:syntastic_less_options = ''
  18. endif
  19. if !exists('g:syntastic_less_use_less_lint')
  20. let g:syntastic_less_use_less_lint = 0
  21. endif
  22. let s:save_cpo = &cpo
  23. set cpo&vim
  24. let s:node_file = 'node ' . syntastic#util#shescape(expand('<sfile>:p:h', 1) . syntastic#util#Slash() . 'less-lint.js')
  25. function! SyntaxCheckers_less_lessc_IsAvailable() dict
  26. call self.log('g:syntastic_less_use_less_lint =', g:syntastic_less_use_less_lint)
  27. return g:syntastic_less_use_less_lint ? executable('node') : executable(self.getExec())
  28. endfunction
  29. function! SyntaxCheckers_less_lessc_GetLocList() dict
  30. if !exists('s:check_file')
  31. let s:check_file = g:syntastic_less_use_less_lint ? s:node_file : self.getExecEscaped()
  32. endif
  33. let makeprg = self.makeprgBuild({
  34. \ 'exe': s:check_file,
  35. \ 'args': g:syntastic_less_options,
  36. \ 'args_after': '--no-color',
  37. \ 'tail': '> ' . syntastic#util#DevNull() })
  38. let errorformat =
  39. \ '%m in %f on line %l\, column %c:,' .
  40. \ '%m in %f:%l:%c,' .
  41. \ '%-G%.%#'
  42. return SyntasticMake({
  43. \ 'makeprg': makeprg,
  44. \ 'errorformat': errorformat,
  45. \ 'postprocess': ['guards'],
  46. \ 'defaults': {'bufnr': bufnr(''), 'text': 'Syntax error'} })
  47. endfunction
  48. call g:SyntasticRegistry.CreateAndRegisterChecker({
  49. \ 'filetype': 'less',
  50. \ 'name': 'lessc'})
  51. let &cpo = s:save_cpo
  52. unlet s:save_cpo
  53. " vim: set sw=4 sts=4 et fdm=marker: