5
|
1 " Vim indent file
|
|
2 " Language: SASS
|
|
3 " Maintainer: Tim Pope <vimNOSPAM@tpope.info>
|
|
4 " Last Change: 2007 Dec 16
|
|
5
|
|
6 if exists("b:did_indent")
|
|
7 finish
|
|
8 endif
|
|
9 let b:did_indent = 1
|
|
10
|
|
11 setlocal autoindent sw=2 et
|
|
12 setlocal indentexpr=GetSassIndent()
|
|
13 setlocal indentkeys=o,O,*<Return>,<:>,!^F
|
|
14
|
|
15 " Only define the function once.
|
|
16 if exists("*GetSassIndent")
|
|
17 finish
|
|
18 endif
|
|
19
|
|
20 let s:property = '^\s*:\|^\s*[[:alnum:]-]\+:'
|
|
21
|
|
22 function! GetSassIndent()
|
|
23 let lnum = prevnonblank(v:lnum-1)
|
|
24 let line = substitute(getline(lnum),'\s\+$','','')
|
|
25 let cline = substitute(substitute(getline(v:lnum),'\s\+$','',''),'^\s\+','','')
|
|
26 let lastcol = strlen(line)
|
|
27 let line = substitute(line,'^\s\+','','')
|
|
28 let indent = indent(lnum)
|
|
29 let cindent = indent(v:lnum)
|
|
30 if line !~ s:property && cline =~ s:property
|
|
31 return indent + &sw
|
|
32 "elseif line =~ s:property && cline !~ s:property
|
|
33 "return indent - &sw
|
|
34 else
|
|
35 return -1
|
|
36 endif
|
|
37 endfunction
|
|
38
|
|
39 " vim:set sw=2:
|