forked from clifford-github/sublime-ansible
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAnsible.sublime-syntax
159 lines (137 loc) · 3.72 KB
/
Ansible.sublime-syntax
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
%YAML 1.2
---
name: Ansible
scope: source.ansible
version: 2
variables:
results: "(failed|succeeded|skipped)"
operatos: |-
(?x:
\b(?:
(is|or)(\snot)?|if|else|(un)?defined
)\b
)
builtin_functions: |-
(?x:
\b(?:
d(efault)?|query|lookup
|combine|selectattr|dict2items
|product|list|query
)\b
)
builtin_tags: |-
(?x:
\b(?:
block|recursive|macro
|call|filter|set|extends|include|raw|debug|with
|autoescape|trans|pluralize|scoped|as|do
)\b
)
contexts:
main:
- match: ""
push: Packages/YAML/YAML.sublime-syntax
with_prototype:
- include: comments
- include: entity-ansible
- include: constant-ansible
- include: jinja
# - include: when-control
comments:
- match: \#
scope: punctuation.definition.comment.ansible
push: comment_line
comment_line:
- meta_scope: comment.line.ansible
- match: $\n?
set: main
entity-ansible:
- match: '- name:.*$'
scope: entity.name.ansible
pop: true
constant-results:
- match: \b{{results}}\b
scope: constant.other.ansible
pop: true
constant-ansible:
- match: 'ansible_((?:\.)?\w+(\[\w\]+)?)+'
scope: constant.other.ansible
when-control:
- match: '(?:(when)(:))'
captures:
1: entity.name.tag.ansible
2: punctuation.separator.ansible
- include: when-body
when-body:
- match: '^\s*-\s.*$'
set: keyword-control
keyword-control:
- match: '\s{{operatos}}\s'
scope: keyword.operator.word.ansible
jinja:
- match: \{{2}
scope: punctuation.definition.placeholder.begin.ansible
push: jinja-body
jinja-body:
- meta_scope: meta.placeholder.ansible
- match: \}{2}
scope: punctuation.definition.placeholder.end.ansible
pop: true
- include: jinja-expressions
jinja-expressions:
- include: match_keywords
- include: constant-ansible
- include: single-functions
- include: functions
match_keywords:
- match: \b(for)\b
scope: keyword.control.loop.for.ansible
- match: \b(if)\b
scope: keyword.control.conditional.if.ansible
- match: \b(else)\b
scope: keyword.control.conditional.else.ansible
- match: \b(elif)\b
scope: keyword.control.conditional.elseif.ansible
- match: \b(continue)\b
scope: keyword.control.flow.continue.ansible
- match: \b(break)\b
scope: keyword.control.flow.break.ansible
- match: '{{builtin_tags}}'
scope: keyword.other.tag.ansible
- match: (\||==|!=)
scope: keyword.other.tag.ansible
single-functions:
- match: (\s{{builtin_functions}}\s)
scope: support.function.global.ansible
functions:
- match: (?:({{builtin_functions}})|(\w+))(\()
captures:
1: support.function.global.ansible
2: variable.function.ansible
3: punctuation.section.arguments.begin.ansible
push:
- meta_content_scope: meta.function-call.arguments.ansible
- match: \)
scope: punctuation.section.arguments.end.ansible
pop: true
- match: '[a-zA-Z0-9_]+'
scope: variable.parameter.ansible
- match: \,
scope: punctuation.separator.parameters.twig
jinja-keyword-control:
- match: (\||==|!=)
scope: keyword.control.ansible
pop: true
jinja-end:
- match: '}}'
scope: punctuation.section.block.end.ansible
pop: true
set:
- include: main
string:
- meta_scope: string.quoted.other.ansible
- match: \'| \"
scope: punctuation.definition.string.begin.ansible
pop: true
- match: \\.
scope: constant.character.escape.ansible