From e68cb5fd220867305e877eb97f6dfefcf5772302 Mon Sep 17 00:00:00 2001 From: Reuh Date: Sun, 11 Aug 2019 16:36:13 +0200 Subject: [PATCH] Updated to latest Lua syntax --- Candran.sublime-build | 0 Candran.sublime-syntax | 808 +++++++++++++++++++++++++++++---- Comments.tmPreferences | 0 Completion Rules.tmPreferences | 0 Indent.tmPreferences | 24 +- Symbol List.tmPreferences | 16 + 6 files changed, 759 insertions(+), 89 deletions(-) mode change 100755 => 100644 Candran.sublime-build mode change 100755 => 100644 Candran.sublime-syntax mode change 100755 => 100644 Comments.tmPreferences mode change 100755 => 100644 Completion Rules.tmPreferences mode change 100755 => 100644 Indent.tmPreferences create mode 100644 Symbol List.tmPreferences diff --git a/Candran.sublime-build b/Candran.sublime-build old mode 100755 new mode 100644 diff --git a/Candran.sublime-syntax b/Candran.sublime-syntax old mode 100755 new mode 100644 index 95ad3f3..175fa55 --- a/Candran.sublime-syntax +++ b/Candran.sublime-syntax @@ -1,95 +1,751 @@ %YAML 1.2 --- -# http://www.sublimetext.com/docs/3/syntax.html name: Candran -comment: "Candran Syntax: version 0.8" +comment: Candran 0.8 syntax file_extensions: - can - candran first_line_match: \A#!.*?\bcan\b scope: source.candran +variables: + reserved_word: |- + (?x:(?: + and|break|do|elseif|else|end|false|for|function|goto|if|in| + local|nil|not|or|repeat|return|then|true|until|while + ){{identifier_break}}) + reserved_word_statement: |- # excludes 'not', 'true', 'nil', 'false', 'function' + (?x:(?: + and|break|do|elseif|else|end|for|goto|if|in| + local|or|repeat|return|then|until|while + ){{identifier_break}}) + + identifier_start: (?:[A-Za-z_]) + identifier_char: (?:[A-Za-z0-9_]) + identifier_break: (?!{{identifier_char}}) + identifier_raw: (?:{{identifier_start}}{{identifier_char}}*) + identifier: (?:(?!{{reserved_word}}){{identifier_raw}}) + + short_function_begin: (?:\:(?=\()|(?=\(\))|(?=\({{identifier}}[=,\)])) + function_args_begin: (?:\(|"|'|\[=*\[|\{) + function_call_ahead: (?=\s*{{function_args_begin}}) + function_assignment_ahead: (?=\s*=\s*(?:function|{{short_function_begin}}){{identifier_break}}) + contexts: main: - - match: '\b(function)\s+([a-zA-Z_.:]+[.:])?([a-zA-Z_]\w*)\s*(\()([^)]*)(\))' - scope: meta.function.lua - captures: - 1: keyword.control.lua - 2: entity.name.function.scope.lua - 3: entity.name.function.lua - 4: punctuation.definition.parameters.begin.lua - 5: variable.parameter.function.lua - 6: punctuation.definition.parameters.end.lua - - match: '(?~]=) + scope: keyword.operator.comparison.candran + push: expression-begin + - match: (?://|[-+*/%^]) + scope: keyword.operator.arithmetic.candran + push: expression-begin + - match: (?:>>|<<|[&|~]) + scope: keyword.operator.bitwise.candran + push: expression-begin + - match: (?:[<>]) + scope: keyword.operator.comparison.candran + push: expression-begin + - match: \.\. + scope: keyword.operator.concatenation.candran + push: expression-begin + - match: = + scope: keyword.operator.assignment.candran + push: expression-begin + - match: (?:and|or){{identifier_break}} + scope: keyword.operator.logical.candran + push: expression-begin + + accessor: + - match: '[.:]' + scope: punctuation.accessor.candran + push: property + + - match: \[ + scope: punctuation.section.brackets.begin.candran + push: + - meta_scope: meta.brackets.candran + - match: \] + scope: punctuation.section.brackets.end.candran + pop: true + - include: reserved-word-expression-pop + - match: (?=\S) + push: expression + + property: + - match: '{{identifier}}{{function_assignment_ahead}}' + scope: meta.property.candran entity.name.function.candran + pop: true + - match: '{{identifier}}{{function_call_ahead}}' + scope: meta.property.candran variable.function.candran + pop: true + - match: '{{identifier}}' + scope: meta.property.candran + pop: true + - include: reserved-word-pop + - include: else-pop + + function-arguments-meta: + - meta_scope: meta.function-call.arguments.candran + - include: immediately-pop + + function-arguments: + - include: string + - include: table-constructor + + - match: \( + scope: punctuation.section.group.begin.candran + set: + - meta_scope: meta.group.candran + - match: \) + scope: punctuation.section.group.end.candran + pop: true + - include: reserved-word-expression-pop + - match: (?=\S) + push: expression-list + + prefix-operator: + - match: '#' + scope: keyword.operator.length.candran + - match: \- + scope: keyword.operator.arithmetic.candran + - match: \~ + scope: keyword.operator.bitwise.candran + - match: not{{identifier_break}} + scope: keyword.operator.logical.candran + + reserved-word-pop: + - match: '{{reserved_word}}' + scope: invalid.unexpected-keyword.candran + pop: true + + reserved-word-expression-pop: + - match: '{{reserved_word_statement}}' + scope: invalid.unexpected-keyword.candran + pop: true + + builtin: + - match: true{{identifier_break}} + scope: constant.language.boolean.true.candran + pop: true + - match: false{{identifier_break}} + scope: constant.language.boolean.true.candran + pop: true + - match: nil{{identifier_break}} + scope: constant.language.null.candran + pop: true + - match: \.\.\. + scope: constant.language.candran + pop: true + - match: self|@{{identifier_break}} + scope: variable.language.this.candran + pop: true + - match: '@{{identifier_start}}' + scope: variable.language.this.candran + pop: true + + support: + - match: |- + (?x:_G|_VERSION){{identifier_break}} + scope: support.constant.builtin.candran + pop: true + + - match: |- + (?x: + assert|collectgarbage|dofile|error|getmetatable|ipairs|load|loadfile + |next|pairs|pcall|print|rawequal|rawget|rawlen|rawset|select + |setmetatable|tonumber|tostring|type|xpcall + |require|getfenv|module|setfenv|unpack + ){{identifier_break}} + scope: support.function.builtin.candran + pop: true + + - include: builtin-modules + + variable: + - match: '{{identifier}}{{function_assignment_ahead}}' + scope: entity.name.function.candran + pop: true + + - match: '{{identifier}}{{function_call_ahead}}' + scope: variable.function.candran + pop: true + + - match: '{{identifier}}' + scope: variable.other.candran + pop: true + + number: + - match: (0[Xx])\h*(?:\.\h*)?(?:[Pp][-+]?\d*)? + scope: constant.numeric.hexadecimal.candran captures: - 1: punctuation.definition.comment.lua - - match: \b(and|or|not|break|do|else|for|if|elseif|return|then|repeat|while|until|end|function|local|in|goto|continue|let|push)\b - scope: keyword.control.lua - - match: '(?=?|(? - - name - Indent - scope - source.candran - settings - decreaseIndentPattern - ^\s*(elseif|else|end|\})\s*$ - increaseIndentPattern - ^.*\b(else|elseif|for|(local\s+)?function|if|repeat|until|while)\b((?!end).)*$|\{\s*$|^.*(\s|,|=):?\([^\(]*\)\s*$ - indentSquareBrackets - + name + Indent + scope + source.candran + settings + + decreaseIndentPattern + (^\s*\b(elsei|elseif|else|end|until)\b.*$|^((?!\{).)*\}\;?.*$) + increaseIndentPattern + ((^\s*\b(((local|let)?[\s\w=]+)?function|repeat|else|elseif|if|while)\b|^.*\b(do|then)\b|^.*([\(\,\=\[\{\+\-\*\/\^\%\&\|\:]|and|or|\/\/|\.\.|\>\>|\<\<)\s*(\(\)|\([A-Za-z_][A-Za-z0-9_]*[=,\)]))((?!\bend\b).)*$|^.*\{((?!\}).)*$) + - diff --git a/Symbol List.tmPreferences b/Symbol List.tmPreferences new file mode 100644 index 0000000..e1ea847 --- /dev/null +++ b/Symbol List.tmPreferences @@ -0,0 +1,16 @@ + + + + name + Symbol List Function + scope + source.candran meta.name.function + settings + + showInSymbolList + 1 + symbolTransformation + s/\s+/ /g; + + +