xref: /vim-8.2.3635/runtime/syntax/objc.vim (revision ae5bce1c)
1" Vim syntax file
2" Language:	    Objective C
3" Maintainer:	    Kazunobu Kuriyama <[email protected]>
4" Ex-maintainer:    Anthony Hodsdon <[email protected]>
5" First Author:	    Valentino Kyriakides <[email protected]>
6" Last Change:	    2005 Apr 13
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"
47
48" Match the ObjC method types
49"
50" NOTE: here I match only the indicators, this looks
51" much nicer and reduces cluttering color highlightings.
52" However, if you prefer full method declaration matching
53" append .* at the end of the next two patterns!
54"
55syn match objcInstMethod    "^\s*-\s*"
56syn match objcFactMethod    "^\s*+\s*"
57
58" To distinguish from a header inclusion from a protocol list.
59syn match objcProtocol display "<[_a-zA-Z][_a-zA-Z0-9]*>" contains=objcType,cType,Type
60
61
62" To distinguish labels from the keyword for a method's parameter.
63syn region objcKeyForMethodParam display
64    \ start="^\s*[_a-zA-Z][_a-zA-Z0-9]*\s*:\s*("
65    \ end=")\s*[_a-zA-Z][_a-zA-Z0-9]*"
66    \ contains=objcType,objcTypeModifier,cType,cStructure,cStorageClass,Type
67
68" Objective-C Constant Strings
69syn match objcSpecial display "%@" contained
70syn region objcString start=+\(@"\|"\)+ skip=+\\\\\|\\"+ end=+"+ contains=cFormat,cSpecial,objcSpecial
71
72" Objective-C Message Expressions
73syn 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
74
75syn cluster cParenGroup add=objcMessage
76syn cluster cPreProcGroup add=objcMessage
77
78" Define the default highlighting.
79" For version 5.7 and earlier: only when not done already
80" For version 5.8 and later: only when an item doesn't have highlighting yet
81if version >= 508 || !exists("did_objc_syntax_inits")
82  if version < 508
83    let did_objc_syntax_inits = 1
84    command -nargs=+ HiLink hi link <args>
85  else
86    command -nargs=+ HiLink hi def link <args>
87  endif
88
89  HiLink objcImport		Include
90  HiLink objcImported		cString
91  HiLink objcTypeModifier	objcType
92  HiLink objcType		Type
93  HiLink objcScopeDecl		Statement
94  HiLink objcInstMethod		Function
95  HiLink objcFactMethod		Function
96  HiLink objcStatement		Statement
97  HiLink objcDirective		Statement
98  HiLink objcKeyForMethodParam	None
99  HiLink objcString		cString
100  HiLink objcSpecial		Special
101  HiLink objcProtocol		None
102  HiLink objcConstant		cConstant
103
104  delcommand HiLink
105endif
106
107let b:current_syntax = "objc"
108
109" vim: ts=8
110