sass.vim 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. "============================================================================
  2. "File: sass.vim
  3. "Description: Syntax checking plugin for syntastic
  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. let buf = bufnr('')
  36. if !syntastic#util#bufVar(buf, 'sass_check_partials') && fnamemodify(bufname(buf), ':t')[0] ==# '_'
  37. return []
  38. endif
  39. let makeprg = self.makeprgBuild({
  40. \ 'args_before': '--cache-location ' . s:sass_cache_location . ' ' . s:imports . ' --check' })
  41. let errorformat =
  42. \ '%E%\m%\%%(Syntax %\)%\?%trror: %m,' .
  43. \ '%+C %.%#,' .
  44. \ '%C on line %l of %f\, %.%#,' .
  45. \ '%C on line %l of %f,' .
  46. \ '%-G %\+from line %.%#,' .
  47. \ '%-G %\+Use --trace for backtrace.,' .
  48. \ '%W%>DEPRECATION WARNING on line %l of %f:,' .
  49. \ '%+C%> %.%#,' .
  50. \ '%W%>WARNING: on line %l of %f:,' .
  51. \ '%+C%> %.%#,' .
  52. \ '%W%>WARNING on line %l of %f: %m,' .
  53. \ '%+C%> %.%#,' .
  54. \ '%W%>WARNING on line %l of %f:,' .
  55. \ '%Z%m,' .
  56. \ '%W%>WARNING: %m,' .
  57. \ '%C on line %l of %f\, %.%#,' .
  58. \ '%C on line %l of %f,' .
  59. \ '%-G %\+from line %.%#,' .
  60. \ 'Syntax %trror on line %l: %m,' .
  61. \ '%-G%.%#'
  62. return SyntasticMake({
  63. \ 'makeprg': makeprg,
  64. \ 'errorformat': errorformat,
  65. \ 'postprocess': ['compressWhitespace'] })
  66. endfunction
  67. call g:SyntasticRegistry.CreateAndRegisterChecker({
  68. \ 'filetype': 'sass',
  69. \ 'name': 'sass'})
  70. let &cpo = s:save_cpo
  71. unlet s:save_cpo
  72. " vim: set sw=4 sts=4 et fdm=marker: