Map q to quit easily when submitting p4 and svn.
[profile.git] / .vim / syntax / perforce.vim
1 " Vim syntax file
2 " Language:       Perforce SCM Spec
3 " Author:         Hari Krishna Dara (hari_vim at yahoo dot com)
4 " Last Modified:  31-Mar-2004 @ 23:32
5 " Plugin Version: 2.1
6 " Revision:       1.0.4
7 " Since Version:  1.4
8 "
9 " TODO:
10 "   Filelog definition can be more complete.
11 "   Don't know all the cases of resolve lines, so it may not be complete.
12
13 " For version 5.x: Clear all syntax items
14 " For version 6.x: Quit when a syntax file was already loaded
15 if version < 600
16   syntax clear
17 elseif exists("b:current_syntax")
18   finish
19 endif
20
21 " Generic interactive command:
22 " View region:
23 syn region perforceView start="^View:$" end="\%$" contains=perforceSpec,perforceViewLine
24 syn region perforceFiles start="^Files:$" end="\%$" contains=perforceSpec,perforceChangeFilesLine,perforceSubmitFilesLine
25 " Exclude View and Files alone, so that they can be matched by the regions.
26 syn match perforceSpecline "^.*\%(\<View\|Files\)\@<!:.*$" contains=perforceSpec
27 syn match perforceSpec "^\S\+:\@=" contains=perforceSpecKey contained
28 syn match perforceSpecKey "^\S\+:\@=" contained
29 syn match perforceViewLine "^\t-\?//[^/[:space:]]\+/.\+$" contains=perforceViewExclude,perforceDepotView,perforceClientView contained
30 syn match perforceViewExclude "\%(^\t\)\@<=-" contained
31 syn match perforceDepotView "\%(^\t-\?\)\@<=//[^/[:space:]]\+/.\+\%(//\)\@=" contained
32 syn match perforceClientView "\%(\t-\?\)\@<!//[^/[:space:]]\+/.\+$" contained
33 syn match perforceChangeFilesLine "^\t//[^/[:space:]]\+/\f\+\t\+#.*$" contains=perforceDepotFile,perforceSubmitType contained
34 syn match perforceSubmitFilesLine "^\t//[^/[:space:]]\+/.*#\d\+ - .*$" contains=perforceDepotFileSpec,perforceSubmitType,perforceChangeNumber " opened, files
35
36
37 " changes
38 syn match perforceChangeItem "^Change \d\+ on \d\+/\d\+/\d\+ .*$" contains=perforceChangeNumber,perforceDate,perforceUserAtClient
39 syn match perforceChangeNumber "\%(^Change \)\@<=\d\+ \@=" contained
40
41
42 " clients
43 syn match perforceClientItem "^Client \S\+ \d\+/\d\+/\d\+ .*$" contains=perforceClientName,perforceDate,perforceClientRoot
44 syn match perforceClientName "\%(^Client \)\@<=\w\+ \@=" contained
45 syn match perforceClientRoot "\%( root \)\@<=\f\+ \@=" contained
46
47
48 " labels
49 syn match perforceLabelItem "^Label \S\+ \d\+/\d\+/\d\+ .*$" contains=perforceLabelName,perforceDate,perforceUserName
50 syn match perforceLabelName "\%(^Label \)\@<=\S\+ \@=" contained
51 syn match perforceUserName "\%('Created by \)\@<=\w\+\.\@=" contained
52
53
54 " branches
55 syn match perforceBranchItem "^Branch \S\+ \d\+/\d\+/\d\+ .*$" contains=perforceBranchName,perforceDate
56 syn match perforceBranchName "\%(^Branch \)\@<=\S\+ \@=" contained
57
58
59 " depots
60 syn match perforceDepotItem "^Depot \S\+ \d\+/\d\+/\d\+ .*$" contains=perforceDepotName,perforceDate
61 syn match perforceDepotName "\%(^Depot \)\@<=\S\+ \@=" contained
62
63
64 " users
65 syn match perforceUserItem "^\w\+ <[^@]\+@[^>]\+> ([^)]\+) .*$" contains=perforceUserName,perforceDate
66 syn match perforceUserName "^\w\+\%( <\)\@=" contained
67
68
69 " jobs
70 syn match perforceJobItem "^\S\+ on \d\+/\d\+/\d\+ by .*$" contains=perforceJobName,perforceDate,perforceClientName
71 syn match perforceJobName "^\S\+\%( on\)\@=" contained
72 syn match perforceClientName "\%( by \)\@<=[^@[:space:]]\+ \@=" contained
73
74
75 " fixes
76 syn match perforceFixItem "^\S\+ fixed by change \d\+.*$" contains=perforceJobName,perforceChangeNumber,perforceDate,perforceUserAtClient
77 syn match perforceJobName "^\S\+\%( fixed \)\@=" contained
78 syn match perforceChangeNumber "\%(by change \)\@<=\d\+ \@=" contained
79
80
81 " opened, files, have etc.
82 " The format of have is different because it contains the local file. 
83 syn match perforceFilelistLine "^//[^/[:space:]]\+/.*#\d\+ - .*$" contains=perforceDepotFileSpec,perforceLocalFile " have
84 syn match perforceFilelistLine "^//[^/[:space:]]\+/.*#\d\+ - \%(branch\|integrate\|edit\|delete\|add\).*$" contains=perforceDepotFileSpec,perforceSubmitType,perforceDefaultSubmitType,perforceChangeNumber " opened, files
85 syn match perforceChangeNumber "\%( change \)\@<=\d\+ \@=" contained
86 syn match perforceSubmitType "\%( - \)\@<=\S\+\%(\%( default\)\? change \)\@="  contained
87 syn match perforceSubmitType "\%(# \)\@<=\S\+$" contained " change.
88 syn match perforceDefaultSubmitType "\<default\%( change \)\@=" contained
89 syn match perforceLocalFile "\%( - \)\@<=.\+$" contained
90
91
92 " filelog
93 syn match perforceFilelogLine "^//depot/\f\+$" contains=perforceDepotFileSpec
94 syn match perforceFilelogLine "^\.\.\. #\d\+ change \d\+ .*$" contains=perforceVerStr,perforceChangeNumber,perforceSubmitType,perforceDate,perforceUserAtClient
95 syn match perforceSubmitType " \@<=\S\+\%( on \)\@=" contained
96
97
98 " resolve
99 " What else can be there other than "merging" and "copy from" ?
100 syn match perforceResolveLine "^\f\+ - \(merging\|copy from\) \f\+.*$" contains=perforceResolveTargetFile,perforceDepotFileSpec
101 syn match perforceResolveLine "^Diff chunks:.*$" contains=perforceNumChunks
102 " Strictly speaking, we should be able to distinguish between local and depot
103 "   file names here, but I don't know how.
104 syn match perforceResolveTargetFile "^\f\+" contained
105 syn match perforceNumChunks "\d\+" contained
106 syn match perforceConflicting "[1-9]\d* conflicting" contained
107 syn match perforceResolveSkipped " - resolve skipped\."
108
109
110 " help.
111 syn region perforceHelp start=" \{4}\w\+ -- " end="\%$" contains=perforceCommands,perforceHelpKeys
112 syn region perforceHelp start=" \{4}Most common Perforce client commands:" end="\%$" contains=perforceCommands,perforceHelpKeys
113 syn region perforceHelp start=" \{4}Perforce client commands:" end="\%$" contains=perforceCommands,perforceHelpKeys
114 syn region perforceHelp start=" \{4}Environment variables used by Perforce:" end="\%$" contains=perforceCommands,perforceHelpKeys
115 syn region perforceHelp start=" \{4}File types supported by Perforce:" end="\%$" contains=perforceCommands,perforceHelpKeys
116 syn region perforceHelp start=" \{3,4}Perforce job views:" end="\%$" contains=perforceCommands,perforceHelpKeys
117 syn region perforceHelp start=" \{4}Specifying file revisions and revision ranges:" end="\%$" contains=perforceHelpVoid,perforceCommands,perforceHelpKeys
118 syn region perforceHelp start=" \{4}Perforce client usage:" end="\%$" contains=perforceCommands,perforceHelpKeys
119 syn region perforceHelp start=" \{4}Perforce views:" end="\%$" contains=perforceCommands,perforceHelpKeys
120 syn keyword perforceHelpKeys contained simple commands environment filetypes
121 syn keyword perforceHelpKeys contained jobview revisions usage views
122 " Don't highlight these.
123 syn match perforceHelpVoid "@change" contained
124 syn match perforceHelpVoid "@client" contained
125 syn match perforceHelpVoid "@label" contained
126 syn match perforceHelpVoid "#have" contained
127 " Needed for help to window to sync correctly.
128 syn sync lines=100
129
130
131 " Common.
132 syn match perforceUserAtClient " by [^@[:space:]]\+@\S\+" contains=perforceUserName,perforceClientName contained
133 syn match perforceClientName "@\@<=\w\+" contained
134 syn match perforceUserName "\%( by \)\@<=[^@[:space:]]\+@\@=" contained
135 syn match perforceDepotFileSpec "//[^/[:space:]]\+/\f\+\(#\d\+\)\?" contains=perforceDepotFile,perforceVerStr contained
136 syn match perforceDepotFile "//[^#[:space:]]\+" contained
137 syn match perforceComment "^\s*#.*$"
138 syn match perforceDate "\<\@<=\d\+/\d\+/\d\+\>\@=" contained
139 syn match perforceVerStr "#\d\+" contains=perforceVerSep,perforceVersion contained
140 syn match perforceVerSep "#" contained
141 syn match perforceVersion "\d\+" contained
142 syn keyword perforceCommands contained add admin annotate branch branches change
143 syn keyword perforceCommands contained changes client clients counter counters
144 syn keyword perforceCommands contained delete depot dirs edit filelog files fix
145 syn keyword perforceCommands contained fixes help info integrate integrated job
146 syn keyword perforceCommands contained labelsync lock logger monitor obliterate
147 syn keyword perforceCommands contained reopen resolve resolved revert review
148 syn keyword perforceCommands contained triggers typemap unlock user users
149 syn keyword perforceCommands contained verify where reviews set submit sync
150 syn keyword perforceCommands contained opened passwd print protect rename
151 syn keyword perforceCommands contained jobs jobspec label labels flush fstat
152 syn keyword perforceCommands contained group groups have depots describe diff
153 syn keyword perforceCommands contained diff2
154
155 hi link perforceLabelName               perforceKeyName
156 hi link perforceBranchName              perforceKeyName
157 hi link perforceDepotName               perforceKeyName
158 hi link perforceJobName                 perforceKeyName
159 hi link perforceClientName              perforceKeyName
160 hi link perforceUserName                perforceKeyName
161 hi link perforceChangeNumber            perforceKeyName
162 hi link perforceResolveTargetFile       perforceDepotFile
163
164 hi def link perforceSpecKey           Label
165 hi def link perforceComment           Comment
166 hi def link perforceNumChunks         Constant
167 hi def link perforceConflicting       Error
168 hi def link perforceResolveSkipped    Error
169 hi def link perforceDate              Constant
170 hi def link perforceCommands          Identifier
171 hi def link perforceHelpKeys          Identifier
172 hi def link perforceClientRoot        Identifier
173 hi def link perforceKeyName           Special
174 hi def link perforceDepotFile         Directory
175 hi def link perforceLocalFile         Identifier
176 hi def link perforceVerSep            Operator
177 hi def link perforceVersion           Constant
178 hi def link perforceSubmitType        Type
179 hi def link perforceDefaultSubmitType WarningMsg
180 hi def link perforceViewExclude       WarningMsg
181 hi def link perforceDepotView         Directory
182 hi def link perforceClientView        Identifier
183
184 let b:current_syntax='perforce'