0
0
mirror of https://github.com/vim/vim.git synced 2025-07-04 23:07:33 -04:00
vim/runtime/indent/sass.vim

40 lines
948 B
VimL
Raw Normal View History

2008-07-13 17:41:49 +00:00
" Vim indent file
2010-05-21 12:05:36 +02:00
" Language: Sass
" Maintainer: Tim Pope <vimNOSPAM@tpope.org>
" Last Change: 2010 May 21
2008-07-13 17:41:49 +00:00
if exists("b:did_indent")
finish
endif
let b:did_indent = 1
setlocal autoindent sw=2 et
setlocal indentexpr=GetSassIndent()
setlocal indentkeys=o,O,*<Return>,<:>,!^F
" Only define the function once.
if exists("*GetSassIndent")
finish
endif
2010-05-21 12:05:36 +02:00
let s:property = '^\s*:\|^\s*[[:alnum:]-]\+\%(:\|\s*=\)'
2008-07-13 17:41:49 +00:00
function! GetSassIndent()
let lnum = prevnonblank(v:lnum-1)
let line = substitute(getline(lnum),'\s\+$','','')
let cline = substitute(substitute(getline(v:lnum),'\s\+$','',''),'^\s\+','','')
let lastcol = strlen(line)
let line = substitute(line,'^\s\+','','')
let indent = indent(lnum)
let cindent = indent(v:lnum)
if line !~ s:property && cline =~ s:property
return indent + &sw
"elseif line =~ s:property && cline !~ s:property
"return indent - &sw
else
return -1
endif
endfunction
" vim:set sw=2: