diff --git a/README.md b/README.md index 76cb79d..c827392 100644 --- a/README.md +++ b/README.md @@ -8,3 +8,4 @@ Languages supported : * Javascript * JSON * XML +* SQL diff --git a/grammars/sql (twig).cson b/grammars/sql (twig).cson new file mode 100644 index 0000000..70e47ff --- /dev/null +++ b/grammars/sql (twig).cson @@ -0,0 +1,765 @@ +'name': 'SQL (Twig)' +'scopeName': 'source.sql.twig' +'fileTypes': [ + 'sql.twig' +] + +'injections': + 'R: source.sql.twig': + 'patterns': [ + { + 'include': '#twig-comment-tags' + } + { + 'include': '#twig-variable-tags' + } + { + 'include': '#twig-expression-tags' + } + ] + +'patterns': [ + { + 'include': 'source.sql', + } +] + +'repository': + 'twig-comment-tags': + 'begin': '{#' + 'beginCaptures': + '0': + 'name': 'punctuation.definition.comment.begin.twig' + 'end': '#}' + 'endCaptures': + '0': + 'name': 'punctuation.definition.comment.end.twig' + 'name': 'comment.block.twig' + + 'twig-variable-tags': + 'begin': '{(?:{|(?<={#))' + 'beginCaptures': + '0': + 'name': 'punctuation.section.tag.twig' + 'end': '}(?:}|(?=#}))' + 'endCaptures': + '0': + 'name': 'punctuation.section.tag.twig' + 'name': 'meta.tag.template.value.twig' + 'patterns': [ + { + 'include': '#twig-constants' + } + { + 'include': '#twig-operators' + } + { + 'include': '#twig-functions-warg' + } + { + 'include': '#twig-functions' + } + { + 'include': '#twig-macros' + } + { + 'include': '#twig-objects' + } + { + 'include': '#twig-properties' + } + { + 'include': '#twig-filters-warg' + } + { + 'include': '#twig-filters' + } + { + 'include': '#twig-filters-warg-ud' + } + { + 'include': '#twig-filters-ud' + } + { + 'include': '#twig-strings' + } + { + 'include': '#twig-arrays' + } + { + 'include': '#twig-hashes' + } + ] + + 'twig-expression-tags': + 'begin': '(?:{|(?<={#))%' + 'beginCaptures': + '0': + 'name': 'punctuation.section.tag.twig' + 'end': '%(?:}|(?=#}))' + 'endCaptures': + '0': + 'name': 'punctuation.section.tag.twig' + 'name': 'meta.tag.template.value.twig' + 'patterns': [ + { + 'include': '#twig-keywords' + } + { + 'include': '#twig-constants' + } + { + 'include': '#twig-operators' + } + { + 'include': '#twig-functions-warg' + } + { + 'include': '#twig-functions' + } + { + 'include': '#twig-macros' + } + { + 'include': '#twig-objects' + } + { + 'include': '#twig-properties' + } + { + 'include': '#twig-filters-warg' + } + { + 'include': '#twig-filters' + } + { + 'include': '#twig-filters-warg-ud' + } + { + 'include': '#twig-filters-ud' + } + { + 'include': '#twig-strings' + } + { + 'include': '#twig-arrays' + } + { + 'include': '#twig-hashes' + } + ] + + # Patterns + 'twig-constants': + 'patterns': [ + { + 'name': 'constant.language.twig' + 'match': '(?i)(?<=[\\s\\[\\(\\{:,])(?:true|false|null|none)(?=[\\s\\)\\]\\}\\,])' + } + { + 'name': 'constant.numeric.twig' + 'match': '(?<=[\\s\\[\\(\\{:,]|\\.\\.|\\*\\*)[0-9]+(?:\\.[0-9]+)?(?=[\\s\\)\\]\\}\\,]|\\.\\.|\\*\\*)' + } + ] + + 'twig-operators': + 'patterns': [ + { + 'captures': + '1': + 'name': 'keyword.operator.arithmetic.twig' + 'match': '(\\+|-|\\*|/|%|//)' + } + { + 'captures': + '1': + 'name': 'keyword.operator.assignment.twig' + 'match': '(?<=\\s)(=|~)(?=\\s)' + } + { + 'captures': + '1': + 'name': 'keyword.operator.bitwise.twig' + 'match': '(?<=\\s)(&|\\||\\^)(?=\\s)' + } + { + 'captures': + '1': + 'name': 'keyword.operator.comparison.twig' + 'match': '(?<=\\s)((?:!|=)=|<=?|>=?|i(?:s|n))(?=\\s)' + } + { + 'captures': + '1': + 'name': 'keyword.operator.logical.twig' + 'match': '(?<=\\s)(not|or|and|\\?|:)(?=\\s)' + } + { + 'captures': + '0': + 'name': 'keyword.operator.arithmetic.twig' + 'match': '(?<=[a-zA-Z0-9_\\x{7f}-\\x{ff}\\]\\)\'"])\\*\\*(?=[a-zA-Z0-9_\\x{7f}-\\x{ff}\'"])' + } + { + 'captures': + '0': + 'name': 'keyword.operator.other.twig' + 'match': '(?<=[a-zA-Z0-9_\\x{7f}-\\x{ff}\\]\\)\'"])\\.\\.(?=[a-zA-Z0-9_\\x{7f}-\\x{ff}\'"])' + } + { + 'captures': + '0': + 'name': 'keyword.operator.other.twig' + 'match': '(?<=[a-zA-Z0-9_\\x{7f}-\\x{ff}\\]\\}\\)\'"])\\|(?=[a-zA-Z_\\x{7f}-\\x{ff}])' + } + ] + + 'twig-functions-warg': + 'begin': '(?<=[\\s\\(\\[\\{:,])([a-zA-Z0-9_\\-]+)\\s*(\\()' + 'beginCaptures': + '1': + 'name': 'support.function.twig' + '2': + 'name': 'punctuation.definition.parameters.begin.twig' + 'end': '\\)' + 'endCaptures': + '0': + 'name': 'punctuation.definition.parameters.end.twig' + 'patterns': [ + { + 'include': '#twig-constants' + } + { + 'include': '#twig-functions-warg' + } + { + 'include': '#twig-functions' + } + { + 'include': '#twig-macros' + } + { + 'include': '#twig-objects' + } + { + 'include': '#twig-properties' + } + { + 'include': '#twig-filters-warg' + } + { + 'include': '#twig-filters' + } + { + 'include': '#twig-filters-warg-ud' + } + { + 'include': '#twig-filters-ud' + } + { + 'include': '#twig-strings' + } + { + 'include': '#twig-arrays' + } + ] + 'contentName': 'meta.function.arguments.twig' + + 'twig-properties': + 'patterns': [ + { + 'captures': + '1': + 'name': 'punctuation.separator.property.twig' + '2': + 'name': 'variable.other.property.twig' + 'match': '(?x)\n (?<=[a-zA-Z0-9_\\x{7f}-\\x{ff}])\n (\\.)([a-zA-Z_\\x{7f}-\\x{ff}][a-zA-Z0-9_\\x{7f}-\\x{ff}]*)\n (?=[\\.\\s\\|\\[\\)\\]\\}:,])\n ' + } + { + 'begin': '(?x)\n (?<=[a-zA-Z0-9_\\x{7f}-\\x{ff}])\n (\\.)([a-zA-Z_\\x{7f}-\\x{ff}][a-zA-Z0-9_\\x{7f}-\\x{ff}]*)\n (\\()\n ' + 'beginCaptures': + '1': + 'name': 'punctuation.separator.property.twig' + '2': + 'name': 'variable.other.property.twig' + '3': + 'name': 'punctuation.definition.parameters.begin.twig' + 'end': '\\)' + 'endCaptures': + '0': + 'name': 'punctuation.definition.parameters.end.twig' + 'patterns': [ + { + 'include': '#twig-constants' + } + { + 'include': '#twig-functions-warg' + } + { + 'include': '#twig-functions' + } + { + 'include': '#twig-macros' + } + { + 'include': '#twig-objects' + } + { + 'include': '#twig-properties' + } + { + 'include': '#twig-filters-warg' + } + { + 'include': '#twig-filters' + } + { + 'include': '#twig-filters-warg-ud' + } + { + 'include': '#twig-filters-ud' + } + { + 'include': '#twig-strings' + } + { + 'include': '#twig-arrays' + } + ] + 'contentName': 'meta.function.arguments.twig' + } + { + 'captures': + '1': + 'name': 'punctuation.section.array.begin.twig' + '2': + 'name': 'variable.other.property.twig' + '3': + 'name': 'punctuation.section.array.end.twig' + '4': + 'name': 'punctuation.section.array.begin.twig' + '5': + 'name': 'variable.other.property.twig' + '6': + 'name': 'punctuation.section.array.end.twig' + '7': + 'name': 'punctuation.section.array.begin.twig' + '8': + 'name': 'variable.other.property.twig' + '9': + 'name': 'punctuation.section.array.end.twig' + 'match': '(?x)\n (?<=[a-zA-Z0-9_\\x{7f}-\\x{ff}\\]])\n (?:\n (\\[)(\'[a-zA-Z_\\x{7f}-\\x{ff}][a-zA-Z0-9_\\x{7f}-\\x{ff}]*\')(\\])\n |(\\[)("[a-zA-Z_\\x{7f}-\\x{ff}][a-zA-Z0-9_\\x{7f}-\\x{ff}]*")(\\])\n |(\\[)([a-zA-Z_\\x{7f}-\\x{ff}][a-zA-Z0-9_\\x{7f}-\\x{ff}]*)(\\])\n )\n ' + } + ] + + 'twig-strings': + 'patterns': [ + { + 'begin': '(?:(?