blob: 45ca50f6892e7eac2c61972ae3f0addc55111acf [file] [log] [blame]
Bram Moolenaarc236c162008-07-13 17:41:49 +00001" Vim indent file
2" Language: SASS
3" Maintainer: Tim Pope <vimNOSPAM@tpope.info>
4" Last Change: 2007 Dec 16
5
6if exists("b:did_indent")
7 finish
8endif
9let b:did_indent = 1
10
11setlocal autoindent sw=2 et
12setlocal indentexpr=GetSassIndent()
13setlocal indentkeys=o,O,*<Return>,<:>,!^F
14
15" Only define the function once.
16if exists("*GetSassIndent")
17 finish
18endif
19
20let s:property = '^\s*:\|^\s*[[:alnum:]-]\+:'
21
22function! 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
37endfunction
38
39" vim:set sw=2: