blob: 4622f00ff8bb7aa77cca19dc7d7e763a9a8857d6 [file] [log] [blame]
Bram Moolenaarc236c162008-07-13 17:41:49 +00001" Vim indent file
Bram Moolenaar7a329912010-05-21 12:05:36 +02002" Language: Sass
3" Maintainer: Tim Pope <vimNOSPAM@tpope.org>
4" Last Change: 2010 May 21
Bram Moolenaarc236c162008-07-13 17:41:49 +00005
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
Bram Moolenaar7a329912010-05-21 12:05:36 +020020let s:property = '^\s*:\|^\s*[[:alnum:]-]\+\%(:\|\s*=\)'
Bram Moolenaarc236c162008-07-13 17:41:49 +000021
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: