sass.vim 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. "============================================================================
  2. "File: sass.vim
  3. "Description: Syntax checking plugin for syntastic.vim
  4. "Maintainer: Martin Grenfell <martin.grenfell 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_sass_sass_checker')
  13. finish
  14. endif
  15. let g:loaded_syntastic_sass_sass_checker = 1
  16. "sass caching for large files drastically speeds up the checking, but store it
  17. "in a temp location otherwise sass puts .sass_cache dirs in the users project
  18. let s:sass_cache_location = syntastic#util#tmpdir()
  19. lockvar s:sass_cache_location
  20. augroup syntastic
  21. autocmd VimLeave * call syntastic#util#rmrf(s:sass_cache_location)
  22. augroup END
  23. "By default do not check partials as unknown variables are a syntax error
  24. if !exists('g:syntastic_sass_check_partials')
  25. let g:syntastic_sass_check_partials = 0
  26. endif
  27. "use compass imports if available
  28. let s:imports = ''
  29. if executable('compass')
  30. let s:imports = '--compass'
  31. endif
  32. let s:save_cpo = &cpo
  33. set cpo&vim
  34. function! SyntaxCheckers_sass_sass_GetLocList() dict
  35. if !g:syntastic_sass_check_partials && expand('%:t', 1)[0] ==# '_'
  36. return []
  37. endif
  38. let makeprg = self.makeprgBuild({
  39. \ 'args_before': '--cache-location ' . s:sass_cache_location . ' ' . s:imports . ' --check' })
  40. let errorformat =
  41. \ '%E%\m%\%%(Syntax %\)%\?%trror: %m,' .
  42. \ '%+C %.%#,' .
  43. \ '%C on line %l of %f\, %.%#,' .
  44. \ '%C on line %l of %f,' .
  45. \ '%-G %\+from line %.%#,' .
  46. \ '%-G %\+Use --trace for backtrace.,' .
  47. \ '%W%>DEPRECATION WARNING on line %l of %f:,' .
  48. \ '%+C%> %.%#,' .
  49. \ '%W%>WARNING: on line %l of %f:,' .
  50. \ '%+C%> %.%#,' .
  51. \ '%W%>WARNING on line %l of %f: %m,' .
  52. \ '%+C%> %.%#,' .
  53. \ '%W%>WARNING on line %l of %f:,' .
  54. \ '%Z%m,' .
  55. \ '%W%>WARNING: %m,' .
  56. \ '%C on line %l of %f\, %.%#,' .
  57. \ '%C on line %l of %f,' .
  58. \ '%-G %\+from line %.%#,' .
  59. \ 'Syntax %trror on line %l: %m,' .
  60. \ '%-G%.%#'
  61. return SyntasticMake({
  62. \ 'makeprg': makeprg,
  63. \ 'errorformat': errorformat,
  64. \ 'postprocess': ['compressWhitespace'] })
  65. endfunction
  66. call g:SyntasticRegistry.CreateAndRegisterChecker({
  67. \ 'filetype': 'sass',
  68. \ 'name': 'sass'})
  69. let &cpo = s:save_cpo
  70. unlet s:save_cpo
  71. " vim: set sw=4 sts=4 et fdm=marker: