diff --git a/BLACKHOLE.sublime-color-scheme b/BLACKHOLE.sublime-color-scheme index 6aef521..3c7ab6b 100644 --- a/BLACKHOLE.sublime-color-scheme +++ b/BLACKHOLE.sublime-color-scheme @@ -416,17 +416,29 @@ "font_style": "" }, { - "name": "Ansible Keyword", - "scope": "keyword.other.ansible", + "name": "Ansible Task Name", + "scope": "keyword.other.ansible.task.name", "foreground": "var(function)", "font_style": "" }, { - "name": "Ansible Title", - "scope": "string.quoted.double.ansible", - "foreground": "var(string)", + "name": "Ansible Task Description", + "scope": "keyword.other.ansible.task.desc", + "foreground": "#65B0D8", "font_style": "bold" }, + { + "name": "Ansible Block", + "scope": "keyword.other.ansible.block", + "foreground": "var(function)", + "font_style": "italic" + }, + { + "name": "Ansible Action Name", + "scope": "keyword.other.ansible.action.name", + "foreground": "#B7AE89", + "font_style": "" + }, { "scope": "entity.name.filename", "foreground": "#DBC33F" diff --git a/README.md b/README.md index 7de1e52..c3ae692 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,7 @@ cd "$(bat --config-dir)/syntaxes" curl -OL# -o "bibop-recipe.sublime-syntax" https://kaos.sh/blackhole-theme-sublime/bibop-recipe.sublime-syntax curl -OL# -o "knf.sublime-syntax" https://kaos.sh/blackhole-theme-sublime/knf.sublime-syntax curl -OL# -o "rpm-spec.sublime-syntax" https://kaos.sh/blackhole-theme-sublime/rpm-spec.sublime-syntax +curl -OL# -o "ansible.sublime-syntax" https://kaos.sh/blackhole-theme-sublime/ansible.sublime-syntax bat cache --build ``` diff --git a/ansible.sublime-syntax b/ansible.sublime-syntax new file mode 100644 index 0000000..bf4b507 --- /dev/null +++ b/ansible.sublime-syntax @@ -0,0 +1,82 @@ +%YAML 1.2 +--- +# https://www.sublimetext.com/docs/syntax.html +name: Ansible +file_extensions: + - yml + - yaml +scope: source.ansible + +contexts: + main: + - include: comments + - include: keywords + - include: jinja + - include: strings + - include: tasks + - include: conditionals + + comments: + - match: ^[\t ]*# + scope: punctuation.definition.comment + push: + - meta_scope: comment.line + - include: pop-on-line-end + - match: ^[\-]{3} + scope: comment.line + + keywords: + - match: \b(true|false)\b + scope: constant.language.boolean.yaml + - match: '\b([0-9]+\.[0-9]*|\.[0-9]+)([eE][+-]?\d+)?\b' + scope: constant.numeric.float + - match: '\b\d+\b' + scope: constant.numeric.integer + + tasks: + - match: (\-) (name)(:)\ +(.*) + scope: keyword.other.ansible.task + captures: + 1: punctuation.separator + 2: keyword.other.ansible.task.name + 3: keyword.operator.assignment + 4: keyword.other.ansible.task.desc + - match: '[ ]{2,}block(:)' + scope: keyword.other.ansible.block + captures: + 1: keyword.operator.assignment + - match: '[ ]{2,}([\w\d]+)(:)' + scope: keyword.other.ansible.action + captures: + 1: keyword.other.ansible.action.name + 2: keyword.operator.assignment + + conditionals: + - match: \b(is|or|and|(or )?not|if|else|(((un)?defined)))\b + scope: constant.character + + strings: + - match: '"' + scope: punctuation.definition.string.begin + push: + - meta_scope: string.quoted.double + - match: '"' + scope: punctuation.definition.string.end + pop: true + - include: jinja-variable + - match: "'" + scope: punctuation.definition.string.begin + push: + - meta_scope: string.quoted.single + - match: "'" + scope: punctuation.definition.string.end + pop: true + - include: jinja-variable + + jinja-variable: + - match: (\{\{ *[^\{\}]+ *\}\})|(\$\{[^\{\}]+\}) + scope: storage.type.ansible + + pop-on-line-end: + - match: $ + pop: true diff --git a/bibop-recipe.sublime-syntax b/bibop-recipe.sublime-syntax index a40003b..44f9657 100644 --- a/bibop-recipe.sublime-syntax +++ b/bibop-recipe.sublime-syntax @@ -1,6 +1,6 @@ %YAML 1.2 --- -# http://www.sublimetext.com/docs/3/syntax.html +# https://www.sublimetext.com/docs/syntax.html name: Bibop Recipe file_extensions: - recipe diff --git a/knf.sublime-syntax b/knf.sublime-syntax index ab20a77..32e9710 100644 --- a/knf.sublime-syntax +++ b/knf.sublime-syntax @@ -1,6 +1,6 @@ %YAML 1.2 --- -# http://www.sublimetext.com/docs/3/syntax.html +# https://www.sublimetext.com/docs/syntax.html name: KNF file_extensions: - knf @@ -34,8 +34,6 @@ contexts: - match: '"' scope: punctuation.definition.string.end.knf pop: true - - include: string-placeholder - - include: string-escaped-char - match: "'" scope: punctuation.definition.string.begin.knf push: @@ -43,8 +41,6 @@ contexts: - match: "'" scope: punctuation.definition.string.end.knf pop: true - - include: string-placeholder - - include: string-escaped-char macroses: - match: \{([A-Za-z0-9_-]{1,}):([A-Za-z0-9_-]{1,})\}