sass.vim 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. " Vim filetype plugin
  2. " Language: Sass
  3. " Maintainer: Tim Pope <vimNOSPAM@tpope.org>
  4. " Last Change: 2023 Dec 28
  5. " Only do this when not done yet for this buffer
  6. if exists("b:did_ftplugin")
  7. finish
  8. endif
  9. let b:did_ftplugin = 1
  10. let b:undo_ftplugin = "setl com< cms< def< inc< inex< ofu< sua<"
  11. setlocal comments=://
  12. setlocal commentstring=//\ %s
  13. setlocal includeexpr=SassIncludeExpr(v:fname)
  14. setlocal omnifunc=csscomplete#CompleteCSS
  15. setlocal suffixesadd=.sass,.scss,.css
  16. if &filetype =~# '\<s[ac]ss]\>'
  17. setlocal iskeyword+=-
  18. setlocal iskeyword+=$
  19. setlocal iskeyword+=%
  20. let b:undo_ftplugin .= ' isk<'
  21. endif
  22. if get(g:, 'sass_recommended_style', 1)
  23. setlocal shiftwidth=2 softtabstop=2 expandtab
  24. let b:undo_ftplugin .= ' sw< sts< et<'
  25. endif
  26. let &l:define = '^\C\v\s*%(\@function|\@mixin|\=)|^\s*%(\$[[:alnum:]-]+:|[%.][:alnum:]-]+\s*%(\{|$))@='
  27. let &l:include = '^\s*@import\s\+\%(url(\)\=["'']\='
  28. function! SassIncludeExpr(file) abort
  29. let partial = substitute(a:file, '\%(.*/\|^\)\zs', '_', '')
  30. if !empty(findfile(partial))
  31. return partial
  32. endif
  33. return a:file
  34. endfunction
  35. " vim:set sw=2: