From 3795acbd170fd8246af792c180dc232a2f95f43f Mon Sep 17 00:00:00 2001 From: sharkdp Date: Fri, 31 May 2019 21:05:34 +0200 Subject: [PATCH] Add '.env' (DotENV) syntax --- .gitmodules | 3 + assets/syntaxes/DotENV | 1 + assets/syntaxes/DotENV.sublime-syntax | 88 +++++++++++++++++++++++++++ 3 files changed, 92 insertions(+) create mode 160000 assets/syntaxes/DotENV create mode 100644 assets/syntaxes/DotENV.sublime-syntax diff --git a/.gitmodules b/.gitmodules index 029f44a9..e94bbcb8 100644 --- a/.gitmodules +++ b/.gitmodules @@ -132,3 +132,6 @@ [submodule "assets/syntaxes/requirementstxt"] path = assets/syntaxes/requirementstxt url = https://github.com/wuub/requirementstxt +[submodule "assets/syntaxes/DotENV"] + path = assets/syntaxes/DotENV + url = https://github.com/zaynali53/DotENV diff --git a/assets/syntaxes/DotENV b/assets/syntaxes/DotENV new file mode 160000 index 00000000..f6cad114 --- /dev/null +++ b/assets/syntaxes/DotENV @@ -0,0 +1 @@ +Subproject commit f6cad1140ccc0a108278748a493f51c8f2d1d7f5 diff --git a/assets/syntaxes/DotENV.sublime-syntax b/assets/syntaxes/DotENV.sublime-syntax new file mode 100644 index 00000000..9b8390e4 --- /dev/null +++ b/assets/syntaxes/DotENV.sublime-syntax @@ -0,0 +1,88 @@ +%YAML 1.2 +--- +# http://www.sublimetext.com/docs/3/syntax.html +name: DotENV +file_extensions: + - .env + - .envrc + - .env.dist + - .env.local + - .env.sample + - .env.example + - .env.test + - .env.test.local + - .env.dev + - .env.development + - .env.development.local + - .env.prod + - .env.production + - .env.production.local + - .env.dusk.local +scope: source.env +contexts: + main: + - match: (#).*$\n? + comment: "Comments - starts with #" + scope: comment.line.number-sign.env + captures: + 1: punctuation.definition.comment.env + - match: (\") + comment: Strings (double) + captures: + 1: punctuation.definition.string.begin.env + push: + - meta_scope: string.quoted.double.env + - match: (\") + captures: + 1: punctuation.definition.string.end + pop: true + - include: interpolation + - include: variable + - include: escape-characters + - match: (\') + comment: Strings (single) + captures: + 1: punctuation.definition.string.begin.env + push: + - meta_scope: string.quoted.single.env + - match: (\') + captures: + 1: punctuation.definition.string.end + pop: true + - match: '(?<=[\w])\s?=' + comment: Assignment Operator + scope: keyword.operator.assignment.env + - match: '([\w]+)(?=\s?\=)' + comment: Variable + scope: variable.other.env + - match: (?i)\s?(export) + comment: Keywords + scope: keyword.other.env + - match: (?i)(?<=\=)\s?(true|false|null) + comment: Constants + scope: constant.language.env + - match: '\b((0(x|X)[0-9a-fA-F]*)|(([0-9]+\.?[0-9]*)|(\.[0-9]+))((e|E)(\+|-)?[0-9]+)?)\b' + comment: Numeric + scope: constant.numeric.env + escape-characters: + - match: '\\[nrt\\\$\"\'']' + scope: constant.character.escape.env + interpolation: + - match: '(\$\{|\{)' + comment: 'Template Syntax: "foo ${bar} {$baz}"' + captures: + 1: string.interpolated.env keyword.other.template.begin.env + push: + - match: '(\})' + captures: + 1: string.interpolated.env keyword.other.template.end.env + pop: true + - match: '(?x)(\$+)?([a-zA-Z_\x{7f}-\x{ff}][a-zA-Z0-9_\x{7f}-\x{ff}]*?\b)' + captures: + 1: punctuation.definition.variable.env variable.other.env + 2: variable.other.env + variable: + - match: '(?x)(\$+)([a-zA-Z_\x{7f}-\x{ff}][a-zA-Z0-9_\x{7f}-\x{ff}]*?\b)' + captures: + 1: punctuation.definition.variable.env variable.other.env + 2: variable.other.env