@@ -26,13 +26,18 @@ repository:
2626 - include : " #vbaLang"
2727
2828 language :
29+ name : source.language.vba
2930 patterns :
3031 - include : " #comments"
32+ - include : " #funcCall"
3133 - include : " #literals"
3234 - include : " #operators"
3335 - include : " #keywords"
34- - include : " #builtins"
3536 - include : " #objectModel"
37+
38+ lineContinuation :
39+ name : support.vba
40+ match : " \\ s*_\\ s*\\ n"
3641
3742 literals :
3843 patterns :
@@ -160,14 +165,6 @@ repository:
160165 name : variable.other.constant.label.vba
161166 match : " (?i)^([a-z][a-z0-9_]*|\\ d+):"
162167
163- builtins :
164- patterns :
165- - include : " #bi-array"
166- repository :
167- kw-array :
168- name : entity.name.function.vba
169- match : " (?i)\\ b(lbound|ubound)\\ b"
170-
171168 objectModel :
172169 patterns :
173170 - include : " #application"
@@ -234,13 +231,28 @@ repository:
234231 match : " (?i)(?<=\\ bAs)\\ s+([A-Z][A-Z0-9_]*)\\ b"
235232
236233 arguments :
237- match : " (?i)[,]?\\ s*([A-Z][A-Z0-9_]*)\\ s*(\\ bas\\ s+[A-Z][A-Z0-9_]*)?\\ s*"
238- captures :
239- 1 :
240- name : variable.parameter.vba
241- 2 :
242- patterns :
243- - include : " #types"
234+ name : source.args.vba
235+ patterns :
236+ - include : " #funcCall"
237+ - include : " #argsVariable"
238+ - include : " #argsLiteral"
239+ - include : " #language"
240+ repository :
241+ argsVariable :
242+ match : " (?i),?\\ s*([a-z][a-z0-9_]*)(?:\\ s*(\\ bas\\ s+[a-z][a-z0-9_]*))?\\ b"
243+ captures :
244+ 1 :
245+ name : variable.parameter.vba
246+ 2 :
247+ patterns :
248+ - include : " #types"
249+
250+ argsLiteral :
251+ match : " (?i),?\\ s*([a-z0-9\" ]*)\\ b"
252+ captures :
253+ 1 :
254+ patterns :
255+ - include : " #types"
244256
245257 comments :
246258 patterns :
@@ -255,8 +267,7 @@ repository:
255267 begin : " '.*\\ s_\\ s*"
256268 end : " \\ n"
257269 patterns :
258- - name : comment.block.continuation.vba
259- match : " \\ s_\\ s*\\ n"
270+ - include : " #lineContinuation"
260271 apostropheComments :
261272 name : comment.line.apostrophe.vba
262273 match : " '.*"
@@ -295,6 +306,7 @@ repository:
295306
296307 method :
297308 name : source.method.vba
309+ # TODO: rethink how this can be done to support line continuation.
298310 begin : " (?i)^\\ s*((?:Public|Private)?\\ b\\ s*(?:Sub|Function))\\ s+([A-Z][A-Z0-9_]*)\\ s*(\\ ()(.*)(\\ ))\\ s+(as\\ s+[A-Z][A-Z0-9_]*)?"
299311 beginCaptures :
300312 # TODO move this to a method signature pattern
@@ -328,6 +340,7 @@ repository:
328340 - include : " #blockLines"
329341 - include : " #variableDeclarations"
330342 - include : " #variableAssignment"
343+ - include : " #funcCall"
331344 - include : " #language"
332345
333346 repository :
@@ -386,13 +399,59 @@ repository:
386399 - include : " #language"
387400
388401 variableAssignment :
389- name : variable.other.assignment .vba
390- match : " (?i)[a-z][a-z0-9_]* = .* "
402+ name : source.varassign .vba
403+ match : " (?i)( [a-z][a-z0-9_]*)( \\ s*= \\ s*)(.*) "
391404 captures :
392- 0 :
405+ 1 :
406+ name : variable.other.assignment.vba
407+ 2 :
408+ name : keyword.operator.assignment.vba
409+ 3 :
410+ name : source.varassign.grp3.vba
393411 patterns :
412+ - include : " #funcCall"
394413 - include : " #language"
395414
415+ funcCall :
416+ begin : " (?i)([a-z][a-z0-9_]*)\\ ("
417+ beginCaptures :
418+ 1 :
419+ name : entity.name.function.call.vba
420+ end : " \\ )"
421+ patterns :
422+ # These calls need to be back to a top level group because
423+ # textMate does not seem to support a repository in a begin/end
424+ - include : " #args"
425+ - include : " #arg"
426+
427+ args :
428+ # The match gates gates an args list. It is not consumed by the
429+ # match immediately because it is passed through captures which
430+ # handles args separately.
431+ match : " .*,.*"
432+ captures :
433+ 0 :
434+ patterns :
435+ - include : " #argsHandler"
436+ repository :
437+ argsHandler :
438+ name : variable.parameter.vba
439+ begin : " [^,]+"
440+ beginCaptures :
441+ 0 :
442+ patterns :
443+ - include : " #lineConcat"
444+ - include : " #language"
445+ end : " ,"
446+ patterns :
447+ - include : " #lineConcat"
448+ - include : " #language"
449+
450+ arg :
451+ name : variable.parameter.vba
452+ patterns :
453+ - include : " #language"
454+
396455
397456 testing :
398457 patterns :
0 commit comments