blob: 5a965a0f1b550db0541fb7b13f5bdc704f304394 [file] [log] [blame]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001" 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: 2004 May 20
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 nil Nil
34syn keyword objcTypeModifier bycopy in out inout oneway
35
36" Match the ObjC #import directive (like C's #include)
37syn region objcImported display contained start=+"+ skip=+\\\\\|\\"+ end=+"+
38syn match objcImported display contained "<[_0-9a-zA-Z.\/]*>"
39syn match objcImport display "^\s*\(%:\|#\)\s*import\>\s*["<]" contains=objcImported
40
41" Match the important ObjC directives
42syn match objcScopeDecl "@public\|@private\|@protected"
43syn match objcDirective "@interface\|@implementation"
44syn match objcDirective "@class\|@end\|@defs"
45syn match objcDirective "@encode\|@protocol\|@selector"
46
47" Match the ObjC method types
48"
49" NOTE: here I match only the indicators, this looks
50" much nicer and reduces cluttering color highlightings.
51" However, if you prefer full method declaration matching
52" append .* at the end of the next two patterns!
53"
54syn match objcInstMethod "^\s*-\s*"
55syn match objcFactMethod "^\s*+\s*"
56
57" To distinguish from a header inclusion from a protocol list.
58syn match objcProtocol display "<[_a-zA-Z][_a-zA-Z0-9]*>" contains=objcType,cType,Type
59
60
61" To distinguish labels from the keyword for a method's parameter.
62syn region objcKeyForMethodParam display
63 \ start="^\s*[_a-zA-Z][_a-zA-Z0-9]*\s*:\s*("
64 \ end=")\s*[_a-zA-Z][_a-zA-Z0-9]*"
65 \ contains=objcType,objcTypeModifier,cType,cStructure,cStorageClass,Type
66
67" Objective-C Constant Strings
68syn match objcSpecial display "%@" contained
69syn region objcString start=+\(@"\|"\)+ skip=+\\\\\|\\"+ end=+"+ contains=cFormat,cSpecial,objcSpecial
70
71" Objective-C Message Expressions
72syn 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
73
74syn cluster cParenGroup add=objcMessage
75syn cluster cPreProcGroup add=objcMessage
76
77" Define the default highlighting.
78" For version 5.7 and earlier: only when not done already
79" For version 5.8 and later: only when an item doesn't have highlighting yet
80if version >= 508 || !exists("did_objc_syntax_inits")
81 if version < 508
82 let did_objc_syntax_inits = 1
83 command -nargs=+ HiLink hi link <args>
84 else
85 command -nargs=+ HiLink hi def link <args>
86 endif
87
88 HiLink objcImport Include
89 HiLink objcImported cString
90 HiLink objcTypeModifier objcType
91 HiLink objcType Type
92 HiLink objcScopeDecl Statement
93 HiLink objcInstMethod Function
94 HiLink objcFactMethod Function
95 HiLink objcStatement Statement
96 HiLink objcDirective Statement
97 HiLink objcKeyForMethodParam None
98 HiLink objcString cString
99 HiLink objcSpecial Special
100 HiLink objcProtocol None
101
102 delcommand HiLink
103endif
104
105let b:current_syntax = "objc"
106
107" vim: ts=8