From 199835d0791d41c264fa1b971ee5b49c8da7aaa7 Mon Sep 17 00:00:00 2001 From: Jakka Prihatna Date: Thu, 13 Sep 2018 14:55:04 +0700 Subject: [PATCH] Fix equal sign highlighting --- syntaxes/env.YAML-tmLanguage | 142 ++++++++++------- syntaxes/env.tmLanguage | 288 ++++++++++++++++++++++++++--------- 2 files changed, 303 insertions(+), 127 deletions(-) diff --git a/syntaxes/env.YAML-tmLanguage b/syntaxes/env.YAML-tmLanguage index aa11ec6..546403a 100644 --- a/syntaxes/env.YAML-tmLanguage +++ b/syntaxes/env.YAML-tmLanguage @@ -6,78 +6,112 @@ fileTypes: [".env", ".env-sample", ".env.example", ".env.local", ".env.dev", ".e uuid: 09d4e117-0975-453d-a74b-c2e525473f97 patterns: - - comment: 'Comments - starts with #' - match: '(#).*$\n?' + - comment: Comments + match: '^\s?(#.*$)\n' + captures: + '1': + patterns: + - include: '#reminder' + - comment: Entries + match: '^\s?(export\s?)*([\w]+)\s?(\=)(.*)$' + captures: + '1': + name: keyword.other.env + '2': + name: variable.other.env + '3': + name: keyword.operator.assignment.env + '4': + patterns: + - include: '#boolean' + - include: '#numeric' + - include: '#string' + - include: '#interpolated' + - include: '#unquoted' +repository: + reminder: + comment: 'Reminder - starts with #' + match: '(#).*' name: comment.line.number-sign.env captures: '1': { name: punctuation.definition.comment.env } - - - comment: Strings (double) - name: string.quoted.double.env - begin: (\") - beginCaptures: - '1': { name: punctuation.definition.string.begin.env } - patterns: - - include: '#interpolation' - - include: '#variable' - - include: '#escape-characters' - end: (\") - endCaptures: - '1': { name: punctuation.definition.string.end } - - - comment: Strings (single) + boolean: + comment: 'Boolean Constants' + match: '(?i)\b(true|false|null)\b(.*)' + captures: + '1': { name: constant.language.env } + '2': + patterns: + - include: '#reminder' + numeric: + comment: Numeric + match: '(?:\+|-)?\b((?:0(?:x|X)[0-9a-fA-F]*)|(?:(?:[0-9]+\.?[0-9]*)|(?:\.[0-9]+))(?:(?:e|E)(?:\+|-)?[0-9]+)?)\b(.*)' + captures: + '1': { name: constant.numeric.env } + '2': + patterns: + - include: '#reminder' + string: + comment: 'Strings (single)' name: string.quoted.single.env - begin: (\') + begin: '(? comment - Comments - starts with # + Comments match - (#).*$\n? - name - comment.line.number-sign.env + ^\s?(#.*$)\n captures 1 - name - punctuation.definition.comment.env + patterns + + + include + #reminder + + comment - Strings (double) - name - string.quoted.double.env - begin - (\") - beginCaptures + Entries + match + ^\s?(export\s?)*([\w]+)\s?(\=)(.*)$ + captures 1 name - punctuation.definition.string.begin.env + keyword.other.env + + 2 + + name + variable.other.env + + 3 + + name + keyword.operator.assignment.env + + 4 + + patterns + + + include + #boolean + + + include + #numeric + + + include + #string + + + include + #interpolated + + + include + #unquoted + + - patterns - + + + repository + + reminder + + comment + Reminder - starts with # + match + (#).* + name + comment.line.number-sign.env + captures + + 1 - include - #interpolation + name + punctuation.definition.comment.env + + + boolean + + comment + Boolean Constants + match + (?i)\b(true|false|null)\b(.*) + captures + + 1 - include - #variable + name + constant.language.env + 2 - include - #escape-characters + patterns + + + include + #reminder + + - - end - (\") - endCaptures + + + numeric + + comment + Numeric + match + (?:\+|-)?\b((?:0(?:x|X)[0-9a-fA-F]*)|(?:(?:[0-9]+\.?[0-9]*)|(?:\.[0-9]+))(?:(?:e|E)(?:\+|-)?[0-9]+)?)\b(.*) + captures 1 name - punctuation.definition.string.end + constant.numeric.env + + 2 + + patterns + + + include + #reminder + + + string comment Strings (single) name string.quoted.single.env begin - (\') + (?<!\\)(\') beginCaptures 1 @@ -94,59 +177,26 @@ end - (\') + (\')(.*) endCaptures 1 name - punctuation.definition.string.end + punctuation.definition.string.end.env + + 2 + + patterns + + + include + #reminder + + - - comment - Assignment Operator - match - (?<=[\w])\s?= - name - keyword.operator.assignment.env - - - comment - Variable - match - ([\w]+)(?=\s?\=) - name - variable.other.env - - - comment - Keywords - match - (?i)\s?(export) - name - keyword.other.env - - - comment - Constants - match - (?i)(?<=\=)\s?(true|false|null) - name - constant.language.env - - - comment - Numeric - match - \b((0(x|X)[0-9a-fA-F]*)|(([0-9]+\.?[0-9]*)|(\.[0-9]+))((e|E)(\+|-)?[0-9]+)?)\b - name - constant.numeric.env - - - repository - interpolation comment @@ -227,6 +277,98 @@ + unquoted + + comment + Strings (none) + name + string.unquoted.env + match + ([^#]*)(#.*)? + captures + + 1 + + patterns + + + include + #interpolation + + + include + #variable + + + include + #escape-characters + + + + 2 + + patterns + + + include + #reminder + + + + + + interpolated + + comment + Strings (double) + name + string.quoted.double.env + begin + (\") + beginCaptures + + 1 + + name + punctuation.definition.string.begin.env + + + patterns + + + include + #interpolation + + + include + #variable + + + include + #escape-characters + + + end + (\")(.*) + endCaptures + + 1 + + name + punctuation.definition.string.end.env + + 2 + + patterns + + + include + #reminder + + + + + - + \ No newline at end of file