sass.vim 994 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. " Vim indent file
  2. " Language: Sass
  3. " Maintainer: Tim Pope <vimNOSPAM@tpope.org>
  4. " Last Change: 2022 Mar 15
  5. if exists("b:did_indent")
  6. finish
  7. endif
  8. let b:did_indent = 1
  9. setlocal autoindent sw=2 et
  10. setlocal indentexpr=GetSassIndent()
  11. setlocal indentkeys=o,O,*<Return>,<:>,!^F
  12. let b:undo_indent = "setl ai< inde< indk<"
  13. " Only define the function once.
  14. if exists("*GetSassIndent")
  15. finish
  16. endif
  17. let s:property = '^\s*:\|^\s*[[:alnum:]#{}-]\+\%(:\|\s*=\)'
  18. let s:extend = '^\s*\%(@extend\|@include\|+\)'
  19. function! GetSassIndent()
  20. let lnum = prevnonblank(v:lnum-1)
  21. let line = substitute(getline(lnum),'\s\+$','','')
  22. let cline = substitute(substitute(getline(v:lnum),'\s\+$','',''),'^\s\+','','')
  23. let lastcol = strlen(line)
  24. let line = substitute(line,'^\s\+','','')
  25. let indent = indent(lnum)
  26. let cindent = indent(v:lnum)
  27. if line !~ s:property && line !~ s:extend && cline =~ s:property
  28. return indent + shiftwidth()
  29. else
  30. return -1
  31. endif
  32. endfunction
  33. " vim:set sw=2: