2 " Language: Objective-C
3 " Maintainer: Kazunobu Kuriyama <kazunobu.kuriyama@nifty.com>
4 " Last Change: 2004 May 16
8 " Only load this indent file when no other was loaded.
9 if exists("b:did_indent")
15 " Set the function to do the work.
16 setlocal indentexpr=GetObjCIndent()
18 " To make a colon (:) suggest an indentation other than a goto/swich label,
19 setlocal indentkeys-=:
20 setlocal indentkeys+=<:>
22 " Only define the function once.
23 if exists("*GetObjCIndent")
27 function s:GetWidth(line, regexp)
28 let end = matchend(a:line, a:regexp)
35 let width = width + &ts - (width % &ts)
42 function s:LeadingWhiteSpace(line)
43 let end = strlen(a:line)
48 if char != " " && char != "\t"
54 let width = width + &ts - (width % &ts)
62 function GetObjCIndent()
63 let theIndent = cindent(v:lnum)
65 let prev_line = getline(v:lnum - 1)
66 let cur_line = getline(v:lnum)
68 if prev_line !~# ":" || cur_line !~# ":"
73 let prev_colon_pos = s:GetWidth(prev_line, ":")
74 let delta = s:GetWidth(cur_line, ":") - s:LeadingWhiteSpace(cur_line)
75 let theIndent = prev_colon_pos - delta