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

55 lines
970 B
VimL
Raw Normal View History

2004-06-13 20:20:40 +00:00
" Vim indent file
2005-06-29 22:40:58 +00:00
" Language: CSS
" Maintainer: Nikolai Weibull <nikolai+work.vim@bitwi.se>
" Latest Revision: 2005-06-29
2004-06-13 20:20:40 +00:00
if exists("b:did_indent")
finish
endif
let b:did_indent = 1
setlocal indentexpr=GetCSSIndent()
2005-06-29 22:40:58 +00:00
setlocal indentkeys=0{,0},!^F,o,O
2004-06-13 20:20:40 +00:00
if exists("*GetCSSIndent")
finish
endif
2005-06-29 22:40:58 +00:00
function s:LookupLine(lnum)
2004-06-13 20:20:40 +00:00
let lnum = prevnonblank(a:lnum - 1)
2005-06-29 22:40:58 +00:00
while lnum > 0
let line = getline(lnum)
if line =~ '\*/'
while lnum > 0 && line !~ '/\*'
let lnum -= 1
let line = getline(lnum)
endwhile
endif
if line !~ '^\s*/\*'
return lnum
end
endwhile
return lnum
2004-06-13 20:20:40 +00:00
endfunction
function GetCSSIndent()
2005-06-29 22:40:58 +00:00
let lnum = prevnonblank(v:lnum - 1)
2004-06-13 20:20:40 +00:00
if lnum == 0
return 0
endif
let ind = indent(lnum)
2005-06-29 22:40:58 +00:00
if substitute(getline(lnum), '/\*.*', '', 'e') =~ '{\(.*}\)\@!'
2004-06-13 20:20:40 +00:00
let ind = ind + &sw
endif
2005-06-29 22:40:58 +00:00
if getline(v:lnum) =~ '^\s*}'
let ind = ind - &sw
2004-06-13 20:20:40 +00:00
endif
return ind
endfunction