comparison runtime/syntax/objc.vim @ 0:76efa0be13f1

Initial revision
author atsuki
date Sat, 10 Nov 2007 15:07:22 +0900
parents
children 67300faee616
comparison
equal deleted inserted replaced
-1:000000000000 0:76efa0be13f1
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
10 if version < 600
11 syntax clear
12 elseif exists("b:current_syntax")
13 finish
14 endif
15
16 if &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
23 endif
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.
32 syn keyword objcStatement self super _cmd
33 syn keyword objcType id Class SEL IMP BOOL
34 syn keyword objcTypeModifier bycopy in out inout oneway
35 syn keyword objcConstant nil Nil
36
37 " Match the ObjC #import directive (like C's #include)
38 syn region objcImported display contained start=+"+ skip=+\\\\\|\\"+ end=+"+
39 syn match objcImported display contained "<[-_0-9a-zA-Z.\/]*>"
40 syn match objcImport display "^\s*\(%:\|#\)\s*import\>\s*["<]" contains=objcImported
41
42 " Match the important ObjC directives
43 syn match objcScopeDecl "@public\|@private\|@protected"
44 syn match objcDirective "@interface\|@implementation"
45 syn match objcDirective "@class\|@end\|@defs"
46 syn match objcDirective "@encode\|@protocol\|@selector"
47 syn 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 "
56 syn match objcInstMethod "^\s*-\s*"
57 syn match objcFactMethod "^\s*+\s*"
58
59 " To distinguish from a header inclusion from a protocol list.
60 syn 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.
64 syn 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
70 syn match objcSpecial display "%@" contained
71 syn region objcString start=+\(@"\|"\)+ skip=+\\\\\|\\"+ end=+"+ contains=cFormat,cSpecial,objcSpecial
72
73 " Objective-C Message Expressions
74 syn 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
76 syn cluster cParenGroup add=objcMessage
77 syn 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
82 if 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
106 endif
107
108 let b:current_syntax = "objc"
109
110 " vim: ts=8