Skip to content

Commit

Permalink
[GitLab] rework to support variable references as well
Browse files Browse the repository at this point in the history
  • Loading branch information
keith-hall committed May 16, 2024
1 parent 8a98f45 commit fa08f52
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 11 deletions.
24 changes: 13 additions & 11 deletions Gitlab CICD.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,6 @@ contexts:
2: punctuation.separator.key-value.yaml

script-block-sequence:
- match: (-)[ \t]+(!reference\b)\s*(\[)
captures:
1: punctuation.definition.block.sequence.item.yaml
2: meta.property.yaml storage.type.tag-handle.yaml
3: meta.sequence.flow.yaml punctuation.definition.sequence.begin.yaml
push: script-reference-flow-sequence-body
- match: (-)[ \t]+(?=\S)
captures:
1: punctuation.definition.block.sequence.item.yaml
Expand All @@ -70,29 +64,37 @@ contexts:
- meta_scope: source.shell.bash.embedded
- include: scope:source.shell.bash.folded

script-reference-flow-sequence-body:
property:
- meta_prepend: true
- match: (!reference\b)\s*(\[)
captures:
1: meta.property.yaml storage.type.tag-handle.yaml
2: meta.sequence.flow.yaml punctuation.definition.sequence.begin.yaml
push: gitlab-reference-flow-sequence-body

gitlab-reference-flow-sequence-body:
- meta_content_scope: meta.sequence.flow.yaml
- match: \]
scope: meta.sequence.flow.yaml punctuation.definition.sequence.end.yaml
pop: 1
- match: ','
scope: punctuation.separator.sequence.yaml
push: after-reference
push: gitlab-after-reference
- match: '[-\w.]+'
scope: constant.other.label.gitlab
- include: flow-pair-no-clear
- include: flow-node-11

after-reference:
gitlab-after-reference:
- match: \w+
scope: constant.other.gitlab
- match: ','
scope: punctuation.separator.sequence.yaml
set: after-reference-type
set: gitlab-after-reference-type
- match: (?=\])
pop: 1

after-reference-type:
gitlab-after-reference-type:
- match: \w+
scope: variable.other.constant.gitlab
pop: 1
Expand Down
8 changes: 8 additions & 0 deletions tests/syntax_test_gitlab_cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -192,5 +192,13 @@ test-vars-1:
test-vars-2:
variables:
MY_VAR: !reference [.vars, variables, IMPORTANT_VAR]
# ^^^^^^^^^^ meta.property storage.type.tag-handle
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.sequence.flow
# ^ punctuation.definition.sequence.begin
# ^^^^^ constant.other.label
# ^ punctuation.separator.sequence
# ^^^^^^^^^ constant.other
# ^ punctuation.separator.sequence
# ^^^^^^^^^^^^^ variable.other.constant
script:
- printenv

0 comments on commit fa08f52

Please sign in to comment.