summaryrefslogtreecommitdiff
path: root/runtime/indent/ld.vim
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2005-07-04 22:49:24 +0000
committerBram Moolenaar <Bram@vim.org>2005-07-04 22:49:24 +0000
commit0dc065ee7c3bd51e5df3926700e409ae74cdfecf (patch)
tree3e2f974603cbba12d3f1dcebf493e7ff2bf54d7f /runtime/indent/ld.vim
parent7d1f5dbc0a254d7524b3f985f2440bf89e037355 (diff)
downloadvim-0dc065ee7c3bd51e5df3926700e409ae74cdfecf.zip
updated for version 7.0102
Diffstat (limited to 'runtime/indent/ld.vim')
-rw-r--r--runtime/indent/ld.vim42
1 files changed, 38 insertions, 4 deletions
diff --git a/runtime/indent/ld.vim b/runtime/indent/ld.vim
index 8b7c03fce..440b106f1 100644
--- a/runtime/indent/ld.vim
+++ b/runtime/indent/ld.vim
@@ -1,7 +1,7 @@
" Vim indent file
" Language: ld(1) script
" Maintainer: Nikolai Weibull <nikolai+work.vim@bitwi.se>
-" Latest Revision: 2005-06-29
+" Latest Revision: 2005-06-30
if exists("b:did_indent")
finish
@@ -15,6 +15,27 @@ if exists("*GetLDIndent")
finish
endif
+function s:prevnonblanknoncomment(lnum)
+ let lnum = a:lnum
+ while lnum > 1
+ let lnum = prevnonblank(lnum)
+ let line = getline(lnum)
+ if line =~ '\*/'
+ while lnum > 1 && line !~ '/\*'
+ let lnum -= 1
+ endwhile
+ if line =~ '^\s*/\*'
+ let lnum -= 1
+ else
+ break
+ endif
+ else
+ break
+ endif
+ endwhile
+ return lnum
+endfunction
+
function s:count_braces(lnum, count_open)
let n_open = 0
let n_close = 0
@@ -39,11 +60,24 @@ function s:count_braces(lnum, count_open)
endfunction
function GetLDIndent()
- let pnum = prevnonblank(v:lnum - 1)
+ let line = getline(v:lnum)
+ if line =~ '^\s*\*'
+ return cindent(v:lnum)
+ elseif line =~ '^\s*}'
+ return indent(v:lnum) - &sw
+ endif
+
+ let pnum = s:prevnonblanknoncomment(v:lnum - 1)
if pnum == 0
return 0
endif
- return indent(pnum) + s:count_braces(pnum, 1) * &sw
- \ - s:count_braces(v:lnum, 0) * &sw
+ let ind = indent(pnum) + s:count_braces(pnum, 1) * &sw
+
+ let pline = getline(pnum)
+ if pline =~ '}\s*$'
+ let ind -= (s:count_braces(pnum, 0) - (pline =~ '^\s*}' ? 1 : 0)) * &sw
+ endif
+
+ return ind
endfunction