Mercurial > hg > RemoteEditor > vim7
comparison runtime/indent/java.vim @ 48:67300faee616 v7-3-618
v7-3-618
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 01 Aug 2012 18:08:28 +0900 |
parents | 76efa0be13f1 |
children |
comparison
equal
deleted
inserted
replaced
47:6c0584ec21b1 | 48:67300faee616 |
---|---|
1 " Vim indent file | 1 " Vim indent file |
2 " Language: Java | 2 " Language: Java |
3 " Maintainer: Toby Allsopp <toby.allsopp@peace.com> (resigned) | 3 " Previous Maintainer: Toby Allsopp <toby.allsopp@peace.com> |
4 " Last Change: 2005 Mar 28 | 4 " Current Maintainer: Hong Xu <xuhdev@gmail.com> |
5 " Last Change: 2012 May 18 | |
6 " Version: 1.0 | |
7 " License: Same as Vim. | |
8 " Copyright (c) 2012 Hong Xu | |
9 " Before 2012, this file is maintained by Toby Allsopp. | |
5 | 10 |
6 " Only load this indent file when no other was loaded. | 11 " Only load this indent file when no other was loaded. |
7 if exists("b:did_indent") | 12 if exists("b:did_indent") |
8 finish | 13 finish |
9 endif | 14 endif |
22 | 27 |
23 " Only define the function once. | 28 " Only define the function once. |
24 if exists("*GetJavaIndent") | 29 if exists("*GetJavaIndent") |
25 finish | 30 finish |
26 endif | 31 endif |
32 let s:keepcpo= &cpo | |
33 set cpo&vim | |
27 | 34 |
28 function! SkipJavaBlanksAndComments(startline) | 35 function! SkipJavaBlanksAndComments(startline) |
29 let lnum = a:startline | 36 let lnum = a:startline |
30 while lnum > 1 | 37 while lnum > 1 |
31 let lnum = prevnonblank(lnum) | 38 let lnum = prevnonblank(lnum) |
58 return theIndent | 65 return theIndent |
59 endif | 66 endif |
60 | 67 |
61 " find start of previous line, in case it was a continuation line | 68 " find start of previous line, in case it was a continuation line |
62 let lnum = SkipJavaBlanksAndComments(v:lnum - 1) | 69 let lnum = SkipJavaBlanksAndComments(v:lnum - 1) |
70 | |
71 " If the previous line starts with '@', we should have the same indent as | |
72 " the previous one | |
73 if getline(lnum) =~ '^\s*@\S\+\s*$' | |
74 return indent(lnum) | |
75 endif | |
76 | |
63 let prev = lnum | 77 let prev = lnum |
64 while prev > 1 | 78 while prev > 1 |
65 let next_prev = SkipJavaBlanksAndComments(prev - 1) | 79 let next_prev = SkipJavaBlanksAndComments(prev - 1) |
66 if getline(next_prev) !~ ',\s*$' | 80 if getline(next_prev) !~ ',\s*$' |
67 break | 81 break |
125 endif | 139 endif |
126 | 140 |
127 return theIndent | 141 return theIndent |
128 endfunction | 142 endfunction |
129 | 143 |
144 let &cpo = s:keepcpo | |
145 unlet s:keepcpo | |
146 | |
130 " vi: sw=2 et | 147 " vi: sw=2 et |