blob: 8829b4939c429adc23e64c0cb14f71fde6008838 [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>
Bram Moolenaar9a7224b2012-04-30 15:56:52 +02006" Last Change: 2012 Apr 30
Bram Moolenaar071d4272004-06-13 20:20:40 +00007
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
Bram Moolenaar9a7224b2012-04-30 15:56:52 +020015let s:keepcpo= &cpo
16set cpo&vim
Bram Moolenaar071d4272004-06-13 20:20:40 +000017
18if &filetype != 'objcpp'
19 " Read the C syntax to start with
20 if version < 600
21 source <sfile>:p:h/c.vim
22 else
23 runtime! syntax/c.vim
24 endif
25endif
26
27" Objective C extentions follow below
28"
29" NOTE: Objective C is abbreviated to ObjC/objc
30" and uses *.h, *.m as file extensions!
31
32
33" ObjC keywords, types, type qualifiers etc.
34syn keyword objcStatement self super _cmd
Bram Moolenaar402d2fe2005-04-15 21:00:38 +000035syn keyword objcType id Class SEL IMP BOOL
Bram Moolenaar071d4272004-06-13 20:20:40 +000036syn keyword objcTypeModifier bycopy in out inout oneway
Bram Moolenaar402d2fe2005-04-15 21:00:38 +000037syn keyword objcConstant nil Nil
Bram Moolenaar071d4272004-06-13 20:20:40 +000038
39" Match the ObjC #import directive (like C's #include)
40syn region objcImported display contained start=+"+ skip=+\\\\\|\\"+ end=+"+
Bram Moolenaar9964e462007-05-05 17:54:07 +000041syn match objcImported display contained "<[-_0-9a-zA-Z.\/]*>"
Bram Moolenaar071d4272004-06-13 20:20:40 +000042syn match objcImport display "^\s*\(%:\|#\)\s*import\>\s*["<]" contains=objcImported
43
44" Match the important ObjC directives
45syn match objcScopeDecl "@public\|@private\|@protected"
46syn match objcDirective "@interface\|@implementation"
47syn match objcDirective "@class\|@end\|@defs"
48syn match objcDirective "@encode\|@protocol\|@selector"
Bram Moolenaar36fc5352006-03-04 21:49:37 +000049syn match objcDirective "@try\|@catch\|@finally\|@throw\|@synchronized"
Bram Moolenaar071d4272004-06-13 20:20:40 +000050
51" Match the ObjC method types
52"
53" NOTE: here I match only the indicators, this looks
54" much nicer and reduces cluttering color highlightings.
55" However, if you prefer full method declaration matching
56" append .* at the end of the next two patterns!
57"
58syn match objcInstMethod "^\s*-\s*"
59syn match objcFactMethod "^\s*+\s*"
60
61" To distinguish from a header inclusion from a protocol list.
62syn match objcProtocol display "<[_a-zA-Z][_a-zA-Z0-9]*>" contains=objcType,cType,Type
63
64
65" To distinguish labels from the keyword for a method's parameter.
66syn region objcKeyForMethodParam display
67 \ start="^\s*[_a-zA-Z][_a-zA-Z0-9]*\s*:\s*("
68 \ end=")\s*[_a-zA-Z][_a-zA-Z0-9]*"
69 \ contains=objcType,objcTypeModifier,cType,cStructure,cStorageClass,Type
70
71" Objective-C Constant Strings
72syn match objcSpecial display "%@" contained
73syn region objcString start=+\(@"\|"\)+ skip=+\\\\\|\\"+ end=+"+ contains=cFormat,cSpecial,objcSpecial
74
75" Objective-C Message Expressions
76syn 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
77
78syn cluster cParenGroup add=objcMessage
79syn cluster cPreProcGroup add=objcMessage
80
81" Define the default highlighting.
82" For version 5.7 and earlier: only when not done already
83" For version 5.8 and later: only when an item doesn't have highlighting yet
84if version >= 508 || !exists("did_objc_syntax_inits")
85 if version < 508
86 let did_objc_syntax_inits = 1
87 command -nargs=+ HiLink hi link <args>
88 else
89 command -nargs=+ HiLink hi def link <args>
90 endif
91
92 HiLink objcImport Include
93 HiLink objcImported cString
94 HiLink objcTypeModifier objcType
95 HiLink objcType Type
96 HiLink objcScopeDecl Statement
97 HiLink objcInstMethod Function
98 HiLink objcFactMethod Function
99 HiLink objcStatement Statement
100 HiLink objcDirective Statement
101 HiLink objcKeyForMethodParam None
102 HiLink objcString cString
103 HiLink objcSpecial Special
104 HiLink objcProtocol None
Bram Moolenaar402d2fe2005-04-15 21:00:38 +0000105 HiLink objcConstant cConstant
Bram Moolenaar071d4272004-06-13 20:20:40 +0000106
107 delcommand HiLink
108endif
109
110let b:current_syntax = "objc"
111
Bram Moolenaar9a7224b2012-04-30 15:56:52 +0200112let &cpo = s:keepcpo
113unlet s:keepcpo
114
Bram Moolenaar071d4272004-06-13 20:20:40 +0000115" vim: ts=8