From 78fd9fb22544e3a0fd039dd3b2501abd29131f03 Mon Sep 17 00:00:00 2001 From: Dull Bananas Date: Fri, 15 Nov 2019 18:37:41 -0700 Subject: [PATCH 1/3] Add jinja syntax --- runtime/syntax/jinja2.yaml | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 runtime/syntax/jinja2.yaml diff --git a/runtime/syntax/jinja2.yaml b/runtime/syntax/jinja2.yaml new file mode 100644 index 00000000..ee6ad08e --- /dev/null +++ b/runtime/syntax/jinja2.yaml @@ -0,0 +1,30 @@ +filetype: jinja2 + +detect: + filename: "\\.html$" + +rules: + - include: "html" + #- special.expression: "({{|}})" + #- default: + # start: "{{" + # end: "}}" + # limit-group: special.expression + # rules: + # - include: "python" + #- special.statement: "({%-?|-?%})" + - special: "({{|}}|{%-?|-?%})" + - default: + start: "({%-?|{{)" + end: "(-?%}|}})" + limit-group: special + rules: + - include: "python" + - statement: "\\b(ignore missing|with(out)? context|block|call|endblock|endcall|endfilter|endfor|endmacro|endraw|endset|extends|filter|for|include|macro|raw|recursive|scoped|set)\\b" + - identifier.builtinfunc: "\\b(attr|batch|capitalize|center|count|d|default|dictsort|e|escape|filesizeformat|first|forceescape|groupby|indent|join|last|length|lower|pprint|random|reject|rejectattr|replace|reverse|safe|select|selectattr|striptags|title|tojson|trim|truncate|unique|upper|urlencode|urlize|wordcount|wordwrap|xmlattr)\\b" + - identifier.builtintest: "\\b(callable|defined|divisibleby|eq|equalto|escaped|even|ge|gt|iterable|le|lower|lt|mapping|ne|none|number|odd|sameas|sequence|string|undefined|upper)\\b" + - identifier.defaultglobal: "\\b(lipsum|cycler|joiner|namespace)\\b" + - comment: + start: "{#" + end: "#}" + rules: [] From 4662f0c5005f6338af6f895acc17f521faf20cc0 Mon Sep 17 00:00:00 2001 From: Dull Bananas Date: Fri, 15 Nov 2019 18:38:33 -0700 Subject: [PATCH 2/3] Remove old code --- runtime/syntax/jinja2.yaml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/runtime/syntax/jinja2.yaml b/runtime/syntax/jinja2.yaml index ee6ad08e..2a1141c6 100644 --- a/runtime/syntax/jinja2.yaml +++ b/runtime/syntax/jinja2.yaml @@ -5,14 +5,6 @@ detect: rules: - include: "html" - #- special.expression: "({{|}})" - #- default: - # start: "{{" - # end: "}}" - # limit-group: special.expression - # rules: - # - include: "python" - #- special.statement: "({%-?|-?%})" - special: "({{|}}|{%-?|-?%})" - default: start: "({%-?|{{)" From 7d1dc1183ca22e15de6c5fb83d2ea09e4c94aec2 Mon Sep 17 00:00:00 2001 From: Dull Bananas Date: Fri, 15 Nov 2019 18:42:17 -0700 Subject: [PATCH 3/3] Improve JavaScript syntax --- runtime/syntax/javascript.yaml | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/runtime/syntax/javascript.yaml b/runtime/syntax/javascript.yaml index dfce4272..e0ffa193 100644 --- a/runtime/syntax/javascript.yaml +++ b/runtime/syntax/javascript.yaml @@ -8,7 +8,8 @@ rules: - constant.number: "\\b[-+]?([1-9][0-9]*|0[0-7]*|0x[0-9a-fA-F]+)([uU][lL]?|[lL][uU]?)?\\b" - constant.number: "\\b[-+]?([0-9]+\\.[0-9]*|[0-9]*\\.[0-9]+)([EePp][+-]?[0-9]+)?[fFlL]?" - constant.number: "\\b[-+]?([0-9]+[EePp][+-]?[0-9]+)[fFlL]?" - - identifier: "[A-Za-z_][A-Za-z0-9_]*[[:space:]]*[(]" + #- identifier: "[A-Za-z_][A-Za-z0-9_]*[[:space:]]*[(]" + # ^ this is not correct usage of the identifier color - symbol.brackets: "(\\{|\\})" - symbol.brackets: "(\\(|\\))" - symbol.brackets: "(\\[|\\])" @@ -20,15 +21,19 @@ rules: - statement: "\\b(for|function|class|extends|get|if|import|from|in|of|instanceof|let|new|return|set)\\b" - statement: "\\b(super|switch|this|throw|try|typeof|var|void|while|with|yield)\\b" # reserved but unassigned - - error: "\\b(enum|implements|interface|package|private|protected|public)" - - constant: "\\b(null|undefined|NaN)\\b" + - error: "\\b(enum|implements|interface|package|private|protected|public|TODO)" + - constant: "\\b(globalThis|Infinity|null|undefined|NaN)\\b" - constant: "\\b(true|false)\\b" - - type: "\\b(Array|Boolean|Date|Enumerator|Error|Function|Math)\\b" + - type: "\\b(Array|Boolean|Date|Enumerator|Error|Function|Math|Map|Set|WeakMap|WeakSet)\\b" - type: "\\b(Number|Object|RegExp|String)\\b" # - constant: "/[^*]([^/]|(\\\\/))*[^\\\\]/[gim]*" - constant: "\\\\[0-7][0-7]?[0-7]?|\\\\x[0-9a-fA-F]+|\\\\[bfnrt'\"\\?\\\\]" - comment: "^#!.*/(env +)?node( |$)" + - identifier: "\\b(alert|decodeURI|decodeURIComponent|document|encodeURI|encodeURIComponent|escape|eval|isFinite|isNaN|parseFloat|parseInt|unescape|uneval|window)\\b" + - identifier: "\\b(Intl|WebAssembly)\\b" + - identifier: "\\b(Arguments)\\b" + - constant.string: start: "\""