diff options
author | Bram Moolenaar <Bram@vim.org> | 2005-06-29 22:40:58 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2005-06-29 22:40:58 +0000 |
commit | 42eeac3552c5a5ea10f24373f76b93633b6c8604 (patch) | |
tree | 902f3158470a3e9c53850708cf982c85c6338796 /runtime/indent/css.vim | |
parent | 24bbcfe8fe62ea43b1cea86243be4fdc8794140b (diff) |
updated for version 7.0097v7.0097
Diffstat (limited to 'runtime/indent/css.vim')
-rw-r--r-- | runtime/indent/css.vim | 73 |
1 files changed, 24 insertions, 49 deletions
diff --git a/runtime/indent/css.vim b/runtime/indent/css.vim index 610c725c69..ee4288cf7c 100644 --- a/runtime/indent/css.vim +++ b/runtime/indent/css.vim @@ -1,79 +1,54 @@ " Vim indent file -" Language: CSS -" Maintainer: Nikolai Weibull <source@pcppopper.org> -" URL: http://www.pcppopper.org/vim/indent/pcp/css/ -" Latest Revision: 2004-04-25 -" arch-tag: ccfd77a0-1c9a-43f7-a407-bbe704541442 +" Language: CSS +" Maintainer: Nikolai Weibull <nikolai+work.vim@bitwi.se> +" Latest Revision: 2005-06-29 -" Only load this indent file when no other was loaded. if exists("b:did_indent") finish endif - let b:did_indent = 1 setlocal indentexpr=GetCSSIndent() -setlocal indentkeys-=:,0# indentkeys-=e +setlocal indentkeys=0{,0},!^F,o,O -" Only define the function once. if exists("*GetCSSIndent") finish endif -function! s:LookupLine(lnum) - " find a non-blank line above the current line +function s:LookupLine(lnum) let lnum = prevnonblank(a:lnum - 1) - - if lnum == 0 - return 0 - endif - - let line = getline(lnum) - - " if the line has an end comment sequence we need to find a line - " that isn't affected by the comment. - if line =~ '\*/' - while line !~ '/\*' - let lnum = lnum - 1 - let line = getline(lnum) - endwhile - endif - - " if the line we found only contained the comment and whitespace - " we need to find another line to use... - if line =~ '^\s*/\*' - return s:LookupLine(lnum) - else - return lnum - endif + 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 = s:LookupLine(v:lnum) - + let lnum = prevnonblank(v:lnum - 1) if lnum == 0 return 0 endif - " remove commented stuff from line - let line = substitute(getline(lnum), '/\*.\*/', '', 'eg') - let ind = indent(lnum) - " check for opening brace on the previous line - " skip if it also contains a closing brace... - if line =~ '{\(.*}\)\@!' + if substitute(getline(lnum), '/\*.*', '', 'e') =~ '{\(.*}\)\@!' let ind = ind + &sw endif - let line = getline(v:lnum) - - " check for closing brace first on current line - if line =~ '^\s*}' - let ind = ind - &sw + if getline(v:lnum) =~ '^\s*}' + let ind = ind - &sw endif return ind endfunction - -" vim: set sts=2 sw=2: |