Skip to content

Commit

Permalink
[D] Add support for named arguments (#3962)
Browse files Browse the repository at this point in the history
Resolves #3961
  • Loading branch information
deathaxe authored Apr 25, 2024
1 parent 2cbefb2 commit 028d843
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 3 deletions.
24 changes: 21 additions & 3 deletions D/D.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,7 @@ contexts:
captures:
1: meta.path.d storage.type.d
2: punctuation.section.parens.begin.d
set: [meta-function-call, uda-after, value-list]
set: [meta-function-call, uda-after, argument-list]
- match: '({{name}})\b'
scope: meta.path.d storage.type.d
set: value-after
Expand Down Expand Up @@ -1284,7 +1284,7 @@ contexts:
- meta_scope: meta.function-call.d
- match: '\('
scope: punctuation.section.parens.begin.d
set: [meta-function-call, value-parens-after, value-list]
set: [meta-function-call, value-parens-after, argument-list]
- match: (?=\S)
set: value-after
new-anonymous-after-args:
Expand Down Expand Up @@ -1401,7 +1401,7 @@ contexts:
set: [value-after, value-identifier]
- match: '\('
scope: punctuation.section.parens.begin.d
set: [meta-function-call, value-parens-after, value-list]
set: [meta-function-call, value-parens-after, argument-list]
- match: '\['
scope: punctuation.section.brackets.begin.d
set: [value-bracket-after, value-list]
Expand Down Expand Up @@ -1497,6 +1497,24 @@ contexts:
set: value-after
- include: not-whitespace-illegal-pop

argument-list:
- match: '(?=\)|}|]|;|:)'
pop: true
- match: '({{name}})\s*(:)'
captures:
1: variable.parameter.d
2: keyword.operator.assignment.d
set: [argument-list-after, value]
- match: '(?=\S)'
set: [argument-list-after, value]
argument-list-after:
- match: '(?=\)|}|]|;|:)'
pop: true
- match: ','
scope: punctuation.separator.sequence.d
set: argument-list
- include: not-whitespace-illegal-pop

value-list:
- match: '(?=\)|}|]|;|:)'
pop: true
Expand Down
12 changes: 12 additions & 0 deletions D/tests/syntax_test_d.d
Original file line number Diff line number Diff line change
Expand Up @@ -3282,3 +3282,15 @@ extern(1)
// ^ keyword.operator.assignment.d
// ^^^^ constant.language.d
// ^ punctuation.terminator.d
myFn(x: 10, y: 20);
// ^^^^^^^^^^^^^^^^^^ meta.function-call.d
// ^ punctuation.section.parens.begin.d
// ^ variable.parameter.d
// ^ keyword.operator.assignment.d
// ^^ constant.numeric.value.d
// ^ punctuation.separator.sequence.d
// ^ variable.parameter.d
// ^ keyword.operator.assignment.d
// ^^ constant.numeric.value.d
// ^ punctuation.section.parens.end.d

0 comments on commit 028d843

Please sign in to comment.