view runtime/indent/css.vim @ 375:f14cbd913415 v7.0097

updated for version 7.0097
author vimboss
date Wed, 29 Jun 2005 22:40:58 +0000
parents 3fc0f57ecb91
children 4fe8e1a7758e
line wrap: on
line source

" Vim indent file
" Language:         CSS
" Maintainer:       Nikolai Weibull <nikolai+work.vim@bitwi.se>
" Latest Revision:  2005-06-29

if exists("b:did_indent")
  finish
endif
let b:did_indent = 1

setlocal indentexpr=GetCSSIndent()
setlocal indentkeys=0{,0},!^F,o,O

if exists("*GetCSSIndent")
  finish
endif

function s:LookupLine(lnum)
  let lnum = prevnonblank(a:lnum - 1)
  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
endfunction

function GetCSSIndent()
  let lnum = prevnonblank(v:lnum - 1)
  if lnum == 0
    return 0
  endif

  let ind = indent(lnum)

  if substitute(getline(lnum), '/\*.*', '', 'e') =~ '{\(.*}\)\@!'
    let ind = ind + &sw
  endif

  if getline(v:lnum) =~ '^\s*}'
    let ind = ind - &sw
  endif

  return ind
endfunction