Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix equal sign highlighting #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
142 changes: 88 additions & 54 deletions syntaxes/env.YAML-tmLanguage
Original file line number Diff line number Diff line change
Expand Up @@ -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: '(?<!\\)(\'')'
beginCaptures:
'1': { name: punctuation.definition.string.begin.env }
end: (\')
end: '(\'')(.*)'
endCaptures:
'1': { name: punctuation.definition.string.end }

- 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:
'1': { name: punctuation.definition.string.end.env }
'2':
patterns:
- include: '#reminder'
interpolation:
comment: 'Template Syntax: "foo ${bar} {$baz}"'
begin: '(\$\{|\{)'
beginCaptures:
'1': { name: string.interpolated.env keyword.other.template.begin.env }
'1': { name: 'string.interpolated.env keyword.other.template.begin.env' }
patterns:
- match: '(?x)(\$+)?([a-zA-Z_\x{7f}-\x{ff}][a-zA-Z0-9_\x{7f}-\x{ff}]*?\b)'
captures:
'1': { name: punctuation.definition.variable.env variable.other.env }
'1': { name: 'punctuation.definition.variable.env variable.other.env' }
'2': { name: variable.other.env }
end: '(\})'
endCaptures:
'1': { name: string.interpolated.env keyword.other.template.end.env }

'1': { name: 'string.interpolated.env keyword.other.template.end.env' }
variable:
patterns:
- match: '(?x)(\$+)([a-zA-Z_\x{7f}-\x{ff}][a-zA-Z0-9_\x{7f}-\x{ff}]*?\b)'
captures:
'1': { name: punctuation.definition.variable.env variable.other.env }
'2': { name: variable.other.env }

- match: '(?x)(\$+)([a-zA-Z_\x{7f}-\x{ff}][a-zA-Z0-9_\x{7f}-\x{ff}]*?\b)'
captures:
'1': { name: 'punctuation.definition.variable.env variable.other.env' }
'2': { name: variable.other.env }
escape-characters:
patterns:
- match: \\[nrt\\\$\"\']
name: constant.character.escape.env
- match: '\\[nrt\\\$\"\'']'
name: constant.character.escape.env
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'
Loading