1" Vim syntax file
2" Language:	    Objective C
3" Maintainer:	    Kazunobu Kuriyama <kazunobu.kuriyama@nifty.com>
4" Ex-maintainer:    Anthony Hodsdon <ahodsdon@fastmail.fm>
5" First Author:	    Valentino Kyriakides <1kyriaki@informatik.uni-hamburg.de>
6" Last Change:	    2007 Feb 21
7
8" For version 5.x: Clear all syntax items
9" For version 6.x: Quit when a syntax file was already loaded
10if version < 600
11  syntax clear
12elseif exists("b:current_syntax")
13  finish
14endif
15
16if &filetype != 'objcpp'
17  " Read the C syntax to start with
18  if version < 600
19    source <sfile>:p:h/c.vim
20  else
21    runtime! syntax/c.vim
22  endif
23endif
24
25" Objective C extentions follow below
26"
27" NOTE: Objective C is abbreviated to ObjC/objc
28" and uses *.h, *.m as file extensions!
29
30
31" ObjC keywords, types, type qualifiers etc.
32syn keyword objcStatement	self super _cmd
33syn keyword objcType		id Class SEL IMP BOOL
34syn keyword objcTypeModifier	bycopy in out inout oneway
35syn keyword objcConstant	nil Nil
36
37" Match the ObjC #import directive (like C's #include)
38syn region objcImported display contained start=+"+  skip=+\\\\\|\\"+  end=+"+
39syn match  objcImported display contained "<[-_0-9a-zA-Z.\/]*>"
40syn match  objcImport display "^\s*\(%:\|#\)\s*import\>\s*["<]" contains=objcImported
41
42" Match the important ObjC directives
43syn match  objcScopeDecl    "@public\|@private\|@protected"
44syn match  objcDirective    "@interface\|@implementation"
45syn match  objcDirective    "@class\|@end\|@defs"
46syn match  objcDirective    "@encode\|@protocol\|@selector"
47syn match  objcDirective    "@try\|@catch\|@finally\|@throw\|@synchronized"
48
49" Match the ObjC method types
50"
51" NOTE: here I match only the indicators, this looks
52" much nicer and reduces cluttering color highlightings.
53" However, if you prefer full method declaration matching
54" append .* at the end of the next two patterns!
55"
56syn match objcInstMethod    "^\s*-\s*"
57syn match objcFactMethod    "^\s*+\s*"
58
59" To distinguish from a header inclusion from a protocol list.
60syn match objcProtocol display "<[_a-zA-Z][_a-zA-Z0-9]*>" contains=objcType,cType,Type
61
62
63" To distinguish labels from the keyword for a method's parameter.
64syn region objcKeyForMethodParam display
65    \ start="^\s*[_a-zA-Z][_a-zA-Z0-9]*\s*:\s*("
66    \ end=")\s*[_a-zA-Z][_a-zA-Z0-9]*"
67    \ contains=objcType,objcTypeModifier,cType,cStructure,cStorageClass,Type
68
69" Objective-C Constant Strings
70syn match objcSpecial display "%@" contained
71syn region objcString start=+\(@"\|"\)+ skip=+\\\\\|\\"+ end=+"+ contains=cFormat,cSpecial,objcSpecial
72
73" Objective-C Message Expressions
74syn region objcMessage display start="\[" end="\]" contains=objcMessage,objcStatement,objcType,objcTypeModifier,objcString,objcConstant,objcDirective,cType,cStructure,cStorageClass,cString,cCharacter,cSpecialCharacter,cNumbers,cConstant,cOperator,cComment,cCommentL,Type
75
76syn cluster cParenGroup add=objcMessage
77syn cluster cPreProcGroup add=objcMessage
78
79" Define the default highlighting.
80" For version 5.7 and earlier: only when not done already
81" For version 5.8 and later: only when an item doesn't have highlighting yet
82if version >= 508 || !exists("did_objc_syntax_inits")
83  if version < 508
84    let did_objc_syntax_inits = 1
85    command -nargs=+ HiLink hi link <args>
86  else
87    command -nargs=+ HiLink hi def link <args>
88  endif
89
90  HiLink objcImport		Include
91  HiLink objcImported		cString
92  HiLink objcTypeModifier	objcType
93  HiLink objcType		Type
94  HiLink objcScopeDecl		Statement
95  HiLink objcInstMethod		Function
96  HiLink objcFactMethod		Function
97  HiLink objcStatement		Statement
98  HiLink objcDirective		Statement
99  HiLink objcKeyForMethodParam	None
100  HiLink objcString		cString
101  HiLink objcSpecial		Special
102  HiLink objcProtocol		None
103  HiLink objcConstant		cConstant
104
105  delcommand HiLink
106endif
107
108let b:current_syntax = "objc"
109
110" vim: ts=8
111