diff --git a/CHANGELOG.md b/CHANGELOG.md index 24baf027..837fc52e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,8 +2,8 @@ ## 0.2.1 (unreleased) -- Fix `base-url` arg to `gutenberg build` being called `base` - +- Fix `base-url` argument to `gutenberg build` being called `base` +- Add syntaxes: Crystal, Elixir, Kotlin ## 0.2.0 (2017-10-05) diff --git a/sublime_syntaxes/Crystal.sublime-syntax b/sublime_syntaxes/Crystal.sublime-syntax new file mode 100644 index 00000000..7e864832 --- /dev/null +++ b/sublime_syntaxes/Crystal.sublime-syntax @@ -0,0 +1,1036 @@ +%YAML 1.2 +--- +# http://www.sublimetext.com/docs/3/syntax.html +name: Crystal +comment: | + TODO: unresolved issues + + text: + "p << end + print me! + end" + symptoms: + not recognized as a heredoc + solution: + there is no way to distinguish perfectly between the << operator and the start + of a heredoc. Currently, we require assignment to recognize a heredoc. More + refinement is possible. + • Heredocs with indented terminators (<<-) are always distinguishable, however. + • Nested heredocs are not really supportable at present + + text: + print <<-'THERE' + This is single quoted. + The above used #{Time.now} + THERE + symtoms: + From Programming Ruby p306; should be a non-interpolated heredoc. + + text: + "a\332a" + symptoms: + '\332' is not recognized as slash3.. which should be octal 332. + solution: + plain regexp.. should be easy. + + text: + val?(a):p(b) + val?'a':'b' + symptoms: + ':p' is recognized as a symbol.. its 2 things ':' and 'p'. + :'b' has same problem. + solution: + ternary operator rule, precedence stuff, symbol rule. + but also consider 'a.b?(:c)' ?? +file_extensions: + - cr +first_line_match: ^#!/.*\bcrystal +scope: source.crystal +contexts: + main: + - match: |- + (?x) + ^ + \s* + (abstract)? + \s* + (class|struct|union) + \s+ + ( + ( + [.A-Z_:\x{80}-\x{10FFFF}][.\w:\x{80}-\x{10FFFF}]* + (\(([,\s.a-zA-Z0-9_:\x{80}-\x{10FFFF}]+)\))? + ( + \s*(<)\s* + [.:A-Z\x{80}-\x{10FFFF}][.:\w\x{80}-\x{10FFFF}]* + (\(([.a-zA-Z0-9_:]+\s,)\))? + )? + )|( + (<<) + \s* + [.A-Z0-9_:\x{80}-\x{10FFFF}]+ + ) + ) + scope: meta.class.crystal + captures: + 1: keyword.control.class.crystal + 2: keyword.control.class.crystal + 3: entity.name.type.class.crystal + 5: punctuation.separator.crystal + 6: support.class.other.type-param.crystal + 7: entity.other.inherited-class.crystal + 8: punctuation.separator.crystal + 9: punctuation.separator.crystal + 10: support.class.other.type-param.crystal + 11: punctuation.definition.variable.crystal + - match: '^\s*(module)\s+(([A-Z\x{80}-\x{10FFFF}][\w\x{80}-\x{10FFFF}]*(::))?([A-Z\x{80}-\x{10FFFF}][\w\x{80}-\x{10FFFF}]*(::))?([A-Z\x{80}-\x{10FFFF}][\w\x{80}-\x{10FFFF}]*(::))*[A-Z\x{80}-\x{10FFFF}][\w\x{80}-\x{10FFFF}]*)' + scope: meta.module.crystal + captures: + 1: keyword.control.module.crystal + 2: entity.name.type.module.crystal + 3: entity.other.inherited-class.module.first.crystal + 4: punctuation.separator.inheritance.crystal + 5: entity.other.inherited-class.module.second.crystal + 6: punctuation.separator.inheritance.crystal + 7: entity.other.inherited-class.module.third.crystal + 8: punctuation.separator.inheritance.crystal + - match: '^\s*(lib)\s+(([A-Z]\w*(::))?([A-Z]\w*(::))?([A-Z]\w*(::))*[A-Z]\w*)' + scope: meta.lib.crystal + captures: + 1: keyword.control.lib.crystal + 2: entity.name.type.lib.crystal + 3: entity.other.inherited-class.lib.first.crystal + 4: punctuation.separator.inheritance.crystal + 5: entity.other.inherited-class.lib.second.crystal + 6: punctuation.separator.inheritance.crystal + 7: entity.other.inherited-class.lib.third.crystal + 8: punctuation.separator.inheritance.crystal + - match: (?|_|\*|\$|\?|:|"|-[0adFiIlpv])' + scope: variable.other.readwrite.global.pre-defined.crystal + captures: + 1: punctuation.definition.variable.crystal + - match: '\b(ENV)\[' + captures: + 1: variable.other.constant.crystal + push: + - meta_scope: meta.environment-variable.crystal + - match: '\]' + pop: true + - include: main + - match: '\b[A-Z\x{80}-\x{10FFFF}][\w\x{80}-\x{10FFFF}]*' + scope: support.class.crystal + - match: '\b[A-Z\x{80}-\x{10FFFF}][\w\x{80}-\x{10FFFF}]*\b' + scope: variable.other.constant.crystal + - match: |- + (?x) + (?=def\b) # an optimization to help Oniguruma fail fast + (?<=^|\s)(def)\s+ # the def keyword + ( (?>[a-zA-Z_\x{80}-\x{10FFFF}][\x{80}-\x{10FFFF}\w]*(?>\.|::))? # a method name prefix + (?>[a-zA-Z_\x{80}-\x{10FFFF}][\x{80}-\x{10FFFF}\w]*(?>[?!]|=(?!>))? # the method name + |===?|>[>=]?|<=>|<[<=]?|[%&`/\|]|\*\*?|=?~|[-+]@?|\[\]=?) ) # …or an operator method + \s*(\() # the openning parenthesis for arguments + comment: the method pattern comes from the symbol pattern, see there for a explaination + captures: + 1: keyword.control.def.crystal + 2: entity.name.function.crystal + 3: punctuation.definition.parameters.crystal + push: + - meta_scope: meta.function.method.with-arguments.crystal + - meta_content_scope: variable.parameter.function.crystal + - match: \)\s*$|\)\s*:|\)\s*; + captures: + 0: punctuation.definition.parameters.crystal + pop: true + - include: main + - match: |- + (?x) + (?=def\b) # an optimization to help Oniguruma fail fast + (?<=^|\s)(def)\s+ # the def keyword + ( (?>[a-zA-Z_\x{80}-\x{10FFFF}][\w\x{80}-\x{10FFFF}]*(?>\.|::))? # a method name prefix + (?>[a-zA-Z_\x{80}-\x{10FFFF}][\w\x{80}-\x{10FFFF}]*(?>[?!]|=(?!>))? # the method name + |===?|>[>=]?|<=>|<[<=]?|[%&`/\|]|\*\*?|=?~|[-+]@?|\[\]=?) ) # …or an operator method + [ \t] # the space separating the arguments + (?=[ \t]*[^\s#;]) # make sure arguments and not a comment follow + comment: same as the previous rule, but without parentheses around the arguments + captures: + 1: keyword.control.def.crystal + 2: entity.name.function.crystal + push: + - meta_scope: meta.function.method.with-arguments.crystal + - meta_content_scope: variable.parameter.function.crystal + - match: $ + pop: true + - include: main + - match: |- + (?x) + (?=def\b) # an optimization to help Oniguruma fail fast + (?<=^|\s)(def)\b # the def keyword + ( \s+ # an optional group of whitespace followed by… + ( (?>[a-zA-Z_\x{80}-\x{10FFFF}][\w\x{80}-\x{10FFFF}]*(?>\.|::))? # a method name prefix + (?>[a-zA-Z_\x{80}-\x{10FFFF}][\w\x{80}-\x{10FFFF}]*(?>[?!]|=(?!>))? # the method name + |===?|>[>=]?|<=>|<[<=]?|[%&`/\|]|\*\*?|=?~|[-+]@?|\[\]=?) ) )? # …or an operator method + comment: the optional name is just to catch the def also without a method-name + scope: meta.function.method.without-arguments.crystal + captures: + 1: keyword.control.def.crystal + 3: entity.name.function.crystal + - match: '\b(0[xX]\h(?>_?\h)*|\d(?>_?\d)*(\.(?![^[:space:][:digit:]])(?>_?\d)*)?([eE][-+]?\d(?>_?\d)*)?|0[bB][01]+|0o[0-7]+)(_?(u8|u16|u32|u64|i8|i16|i32|i64|f32|f64))?\b' + scope: constant.numeric.crystal + - match: ":'" + captures: + 0: punctuation.definition.constant.crystal + push: + - meta_scope: constant.other.symbol.single-quoted.crystal + - match: "'" + captures: + 0: punctuation.definition.constant.crystal + pop: true + - match: '\\[''\\]' + scope: constant.character.escape.crystal + - match: ':"' + captures: + 0: punctuation.definition.constant.crystal + push: + - meta_scope: constant.other.symbol.double-quoted.crystal + - match: '"' + captures: + 0: punctuation.definition.constant.crystal + pop: true + - include: interpolated_crystal + - include: escaped_char + - match: /= + comment: Needs higher precidence than regular expressions. + scope: keyword.operator.assignment.augmented.crystal + - match: "'" + comment: single quoted string (does not allow interpolation) + captures: + 0: punctuation.definition.string.begin.crystal + push: + - meta_scope: string.quoted.single.crystal + - match: "'" + captures: + 0: punctuation.definition.string.end.crystal + pop: true + - match: \\'|\\\\ + scope: constant.character.escape.crystal + - match: '"' + comment: double quoted string (allows for interpolation) + captures: + 0: punctuation.definition.string.begin.crystal + push: + - meta_scope: string.quoted.double.crystal + - match: '"' + captures: + 0: punctuation.definition.string.end.crystal + pop: true + - include: interpolated_crystal + - include: escaped_char + - match: "`" + comment: execute string (allows for interpolation) + captures: + 0: punctuation.definition.string.begin.crystal + push: + - meta_scope: string.interpolated.crystal + - match: "`" + captures: + 0: punctuation.definition.string.end.crystal + pop: true + - include: interpolated_crystal + - include: escaped_char + - match: '%x\{' + comment: execute string (allow for interpolation) + captures: + 0: punctuation.definition.string.begin.crystal + push: + - meta_scope: string.interpolated.crystal + - match: '\}' + captures: + 0: punctuation.definition.string.end.crystal + pop: true + - include: interpolated_crystal + - include: escaped_char + - include: nest_curly_i + - match: '%x\[' + comment: execute string (allow for interpolation) + captures: + 0: punctuation.definition.string.begin.crystal + push: + - meta_scope: string.interpolated.crystal + - match: '\]' + captures: + 0: punctuation.definition.string.end.crystal + pop: true + - include: interpolated_crystal + - include: escaped_char + - include: nest_brackets_i + - match: '%x\<' + comment: execute string (allow for interpolation) + captures: + 0: punctuation.definition.string.begin.crystal + push: + - meta_scope: string.interpolated.crystal + - match: \> + captures: + 0: punctuation.definition.string.end.crystal + pop: true + - include: interpolated_crystal + - include: escaped_char + - include: nest_ltgt_i + - match: '%x\(' + comment: execute string (allow for interpolation) + captures: + 0: punctuation.definition.string.begin.crystal + push: + - meta_scope: string.interpolated.crystal + - match: \) + captures: + 0: punctuation.definition.string.end.crystal + pop: true + - include: interpolated_crystal + - include: escaped_char + - include: nest_parens_i + - match: '%x([^\w])' + comment: execute string (allow for interpolation) + captures: + 0: punctuation.definition.string.begin.crystal + push: + - meta_scope: string.interpolated.crystal + - match: \1 + captures: + 0: punctuation.definition.string.end.crystal + pop: true + - include: interpolated_crystal + - include: escaped_char + - match: |- + (?x) + (?: + ^ # beginning of line + | (?<= # or look-behind on: + [=>~(?:\[,|&;] + | [\s;]if\s # keywords + | [\s;]elsif\s + | [\s;]while\s + | [\s;]unless\s + | [\s;]when\s + | [\s;]assert_match\s + | [\s;]or\s # boolean opperators + | [\s;]and\s + | [\s;]not\s + | [\s.]index\s # methods + | [\s.]scan\s + | [\s.]sub\s + | [\s.]sub!\s + | [\s.]gsub\s + | [\s.]gsub!\s + | [\s.]match\s + ) + | (?<= # or a look-behind with line anchor: + ^when\s # duplication necessary due to limits of regex + | ^if\s + | ^elsif\s + | ^while\s + | ^unless\s + ) + ) + \s*((/))(?![*+{}?]) + comment: | + regular expressions (normal) + we only start a regexp if the character before it (excluding whitespace) + is what we think is before a regexp + captures: + 1: string.regexp.classic.crystal + 2: punctuation.definition.string.crystal + push: + - meta_content_scope: string.regexp.classic.crystal + - match: "((/[eimnosux]*))" + captures: + 1: string.regexp.classic.crystal + 2: punctuation.definition.string.crystal + pop: true + - include: regex_sub + - match: '%r\{' + comment: regular expressions (literal) + captures: + 0: punctuation.definition.string.begin.crystal + push: + - meta_scope: string.regexp.mod-r.crystal + - match: '\}[eimnosux]*' + captures: + 0: punctuation.definition.string.end.crystal + pop: true + - include: regex_sub + - include: nest_curly_r + - match: '%r\[' + comment: regular expressions (literal) + captures: + 0: punctuation.definition.string.begin.crystal + push: + - meta_scope: string.regexp.mod-r.crystal + - match: '\][eimnosux]*' + captures: + 0: punctuation.definition.string.end.crystal + pop: true + - include: regex_sub + - include: nest_brackets_r + - match: '%r\(' + comment: regular expressions (literal) + captures: + 0: punctuation.definition.string.begin.crystal + push: + - meta_scope: string.regexp.mod-r.crystal + - match: '\)[eimnosux]*' + captures: + 0: punctuation.definition.string.end.crystal + pop: true + - include: regex_sub + - include: nest_parens_r + - match: '%r\<' + comment: regular expressions (literal) + captures: + 0: punctuation.definition.string.begin.crystal + push: + - meta_scope: string.regexp.mod-r.crystal + - match: '\>[eimnosux]*' + captures: + 0: punctuation.definition.string.end.crystal + pop: true + - include: regex_sub + - include: nest_ltgt_r + - match: '%r([^\w])' + comment: regular expressions (literal) + captures: + 0: punctuation.definition.string.begin.crystal + push: + - meta_scope: string.regexp.mod-r.crystal + - match: '\1[eimnosux]*' + captures: + 0: punctuation.definition.string.end.crystal + pop: true + - include: regex_sub + - match: '%[QWSR]?\(' + comment: literal capable of interpolation () + captures: + 0: punctuation.definition.string.begin.crystal + push: + - meta_scope: string.quoted.other.literal.upper.crystal + - match: \) + captures: + 0: punctuation.definition.string.end.crystal + pop: true + - include: interpolated_crystal + - include: escaped_char + - include: nest_parens_i + - match: '%[QWSR]?\[' + comment: "literal capable of interpolation []" + captures: + 0: punctuation.definition.string.begin.crystal + push: + - meta_scope: string.quoted.other.literal.upper.crystal + - match: '\]' + captures: + 0: punctuation.definition.string.end.crystal + pop: true + - include: interpolated_crystal + - include: escaped_char + - include: nest_brackets_i + - match: '%[QWSR]?\<' + comment: literal capable of interpolation <> + captures: + 0: punctuation.definition.string.begin.crystal + push: + - meta_scope: string.quoted.other.literal.upper.crystal + - match: \> + captures: + 0: punctuation.definition.string.end.crystal + pop: true + - include: interpolated_crystal + - include: escaped_char + - include: nest_ltgt_i + - match: '%[QWSR]?\{' + comment: "literal capable of interpolation -- {}" + captures: + 0: punctuation.definition.string.begin.crystal + push: + - meta_scope: string.quoted.double.crystal.mod + - match: '\}' + captures: + 0: punctuation.definition.string.end.crystal + pop: true + - include: interpolated_crystal + - include: escaped_char + - include: nest_curly_i + - match: '%[QWSR]([^\w])' + comment: literal capable of interpolation -- wildcard + captures: + 0: punctuation.definition.string.begin.crystal + push: + - meta_scope: string.quoted.other.literal.upper.crystal + - match: \1 + captures: + 0: punctuation.definition.string.end.crystal + pop: true + - include: interpolated_crystal + - include: escaped_char + - match: '%[qws]\(' + comment: literal incapable of interpolation -- () + captures: + 0: punctuation.definition.string.begin.crystal + push: + - meta_scope: string.quoted.other.literal.lower.crystal + - match: \) + captures: + 0: punctuation.definition.string.end.crystal + pop: true + - match: \\\)|\\\\ + scope: constant.character.escape.crystal + - include: nest_parens + - match: '%[qws]\<' + comment: literal incapable of interpolation -- <> + captures: + 0: punctuation.definition.string.begin.crystal + push: + - meta_scope: string.quoted.other.literal.lower.crystal + - match: \> + captures: + 0: punctuation.definition.string.end.crystal + pop: true + - match: \\\>|\\\\ + scope: constant.character.escape.crystal + - include: nest_ltgt + - match: '%[qws]\[' + comment: "literal incapable of interpolation -- []" + captures: + 0: punctuation.definition.string.begin.crystal + push: + - meta_scope: string.quoted.other.literal.lower.crystal + - match: '\]' + captures: + 0: punctuation.definition.string.end.crystal + pop: true + - match: '\\\]|\\\\' + scope: constant.character.escape.crystal + - include: nest_brackets + - match: '%[qws]\{' + comment: "literal incapable of interpolation -- {}" + captures: + 0: punctuation.definition.string.begin.crystal + push: + - meta_scope: string.quoted.other.literal.lower.crystal + - match: '\}' + captures: + 0: punctuation.definition.string.end.crystal + pop: true + - match: '\\\}|\\\\' + scope: constant.character.escape.crystal + - include: nest_curly + - match: '%[qws]([^\w])' + comment: literal incapable of interpolation -- wildcard + captures: + 0: punctuation.definition.string.begin.crystal + push: + - meta_scope: string.quoted.other.literal.lower.crystal + - match: \1 + captures: + 0: punctuation.definition.string.end.crystal + pop: true + - match: \\. + comment: Cant be named because its not neccesarily an escape. + - match: '(?[a-zA-Z_\x{80}-\x{10FFFF}][\w\x{80}-\x{10FFFF}]*(?>[?!]|=(?![>=]))?|===?|>[>=]?|<[<=]?|<=>|[%&`/\|]|\*\*?|=?~|[-+]@?|\[\]=?|@@?[a-zA-Z_\x{80}-\x{10FFFF}][\w\x{80}-\x{10FFFF}]*)' + comment: symbols + scope: constant.other.symbol.crystal + captures: + 1: punctuation.definition.constant.crystal + - match: '(?>[a-zA-Z_\x{80}-\x{10FFFF}][\w\x{80}-\x{10FFFF}]*(?>[?!])?)(:)(?!:)' + comment: symbols + scope: constant.other.symbol.crystal.19syntax + captures: + 1: punctuation.definition.constant.crystal + - match: '(?:^[ \t]+)?(#).*$\n?' + scope: comment.line.number-sign.crystal + captures: + 1: punctuation.definition.comment.crystal + - match: ^__END__\n + comment: __END__ marker + captures: + 0: string.unquoted.program-block.crystal + push: + - meta_content_scope: text.plain + - match: (?=not)impossible + captures: + 0: string.unquoted.program-block.crystal + pop: true + - match: (?=<<-("?)((?:[_\w]+_|)HTML)\b\1)' + comment: heredoc with embedded HTML and indented terminator + captures: + 0: punctuation.definition.string.begin.crystal + push: + - meta_scope: string.unquoted.embedded.html.crystal + - meta_content_scope: text.html.embedded.crystal + - match: \s*\2$ + captures: + 0: punctuation.definition.string.end.crystal + pop: true + - include: heredoc + - include: scope:text.html.basic + - include: interpolated_crystal + - include: escaped_char + - match: '(?><<-("?)((?:[_\w]+_|)SQL)\b\1)' + comment: heredoc with embedded SQL and indented terminator + captures: + 0: punctuation.definition.string.begin.crystal + push: + - meta_scope: string.unquoted.embedded.sql.crystal + - meta_content_scope: text.sql.embedded.crystal + - match: \s*\2$ + captures: + 0: punctuation.definition.string.end.crystal + pop: true + - include: heredoc + - include: scope:source.sql + - include: interpolated_crystal + - include: escaped_char + - match: '(?><<-("?)((?:[_\w]+_|)CSS)\b\1)' + comment: heredoc with embedded css and intented terminator + captures: + 0: punctuation.definition.string.begin.crystal + push: + - meta_scope: string.unquoted.embedded.css.crystal + - meta_content_scope: text.css.embedded.crystal + - match: \s*\2$ + captures: + 0: punctuation.definition.string.end.crystal + pop: true + - include: heredoc + - include: scope:source.css + - include: interpolated_crystal + - include: escaped_char + - match: '(?><<-("?)((?:[_\w]+_|)CPP)\b\1)' + comment: heredoc with embedded c++ and intented terminator + captures: + 0: punctuation.definition.string.begin.crystal + push: + - meta_scope: string.unquoted.embedded.cplusplus.crystal + - meta_content_scope: text.c++.embedded.crystal + - match: \s*\2$ + captures: + 0: punctuation.definition.string.end.crystal + pop: true + - include: heredoc + - include: scope:source.c++ + - include: interpolated_crystal + - include: escaped_char + - match: '(?><<-("?)((?:[_\w]+_|)C)\b\1)' + comment: heredoc with embedded c++ and intented terminator + captures: + 0: punctuation.definition.string.begin.crystal + push: + - meta_scope: string.unquoted.embedded.c.crystal + - meta_content_scope: text.c.embedded.crystal + - match: \s*\2$ + captures: + 0: punctuation.definition.string.end.crystal + pop: true + - include: heredoc + - include: scope:source.c + - include: interpolated_crystal + - include: escaped_char + - match: '(?><<-("?)((?:[_\w]+_|)(?:JS|JAVASCRIPT))\b\1)' + comment: heredoc with embedded javascript and intented terminator + captures: + 0: punctuation.definition.string.begin.crystal + push: + - meta_scope: string.unquoted.embedded.js.crystal + - meta_content_scope: text.js.embedded.crystal + - match: \s*\2$ + captures: + 0: punctuation.definition.string.end.crystal + pop: true + - include: heredoc + - include: scope:source.js + - include: interpolated_crystal + - include: escaped_char + - match: '(?><<-("?)((?:[_\w]+_|)JQUERY)\b\1)' + comment: heredoc with embedded javascript and intented terminator + captures: + 0: punctuation.definition.string.begin.crystal + push: + - meta_scope: string.unquoted.embedded.js.jquery.crystal + - meta_content_scope: text.js.jquery.embedded.crystal + - match: \s*\2$ + captures: + 0: punctuation.definition.string.end.crystal + pop: true + - include: heredoc + - include: scope:source.js.jquery + - include: interpolated_crystal + - include: escaped_char + - match: '(?><<-("?)((?:[_\w]+_|)(?:SH|SHELL))\b\1)' + comment: heredoc with embedded shell and intented terminator + captures: + 0: punctuation.definition.string.begin.crystal + push: + - meta_scope: string.unquoted.embedded.shell.crystal + - meta_content_scope: text.shell.embedded.crystal + - match: \s*\2$ + captures: + 0: punctuation.definition.string.end.crystal + pop: true + - include: heredoc + - include: scope:source.shell + - include: interpolated_crystal + - include: escaped_char + - match: '(?><<-("?)((?:[_\w]+_|)RUBY)\b\1)' + comment: heredoc with embedded crystal and intented terminator + captures: + 0: punctuation.definition.string.begin.crystal + push: + - meta_scope: string.unquoted.embedded.crystal.crystal + - meta_content_scope: text.crystal.embedded.crystal + - match: \s*\2$ + captures: + 0: punctuation.definition.string.end.crystal + pop: true + - include: heredoc + - include: scope:source.crystal + - include: interpolated_crystal + - include: escaped_char + - match: (?>\=\s*<<(\w+)) + captures: + 0: punctuation.definition.string.begin.crystal + push: + - meta_scope: string.unquoted.heredoc.crystal + - match: ^\1$ + captures: + 0: punctuation.definition.string.end.crystal + pop: true + - include: heredoc + - include: interpolated_crystal + - include: escaped_char + - match: (?><<-(\w+)) + comment: heredoc with indented terminator + captures: + 0: punctuation.definition.string.begin.crystal + push: + - meta_scope: string.unquoted.heredoc.crystal + - match: \s*\1$ + captures: + 0: punctuation.definition.string.end.crystal + pop: true + - include: heredoc + - include: interpolated_crystal + - include: escaped_char + - match: '(?<=\{|do|\{\s|do\s)(\|)' + captures: + 1: punctuation.separator.variable.crystal + push: + - match: (\|) + captures: + 1: punctuation.separator.variable.crystal + pop: true + - match: "[_a-zA-Z][_a-zA-Z0-9]*" + scope: variable.other.block.crystal + - match: "," + scope: punctuation.separator.variable.crystal + - match: "=>" + scope: punctuation.separator.key-value + - match: '<<=|%=|&=|\*=|\*\*=|\+=|\-=|\^=|\|{1,2}=|<<' + scope: keyword.operator.assignment.augmented.crystal + - match: '<=>|<(?!<|=)|>(?!<|=|>)|<=|>=|===|==|=~|!=|!~|(?<=[ \t])\?' + scope: keyword.operator.comparison.crystal + - match: '(?<=[ \t])!+|\bnot\b|&&|\band\b|\|\||\bor\b|\^' + scope: keyword.operator.logical.crystal + - match: '(\{\%|\%\}|\{\{|\}\})' + scope: keyword.operator.macro.crystal + - match: (%|&|\*\*|\*|\+|\-|/) + scope: keyword.operator.arithmetic.crystal + - match: "=" + scope: keyword.operator.assignment.crystal + - match: \||~|>> + scope: keyword.operator.other.crystal + - match: ":" + scope: punctuation.separator.other.crystal + - match: \; + scope: punctuation.separator.statement.crystal + - match: "," + scope: punctuation.separator.object.crystal + - match: '\.|::' + scope: punctuation.separator.method.crystal + - match: '\{|\}' + scope: punctuation.section.scope.crystal + - match: '\[|\]' + scope: punctuation.section.array.crystal + - match: \(|\) + scope: punctuation.section.function.crystal + escaped_char: + - match: '\\(?:[0-7]{1,3}|x[\da-fA-F]{1,2}|.)' + scope: constant.character.escape.crystal + heredoc: + - match: ^<<-?\w+ + push: + - match: $ + pop: true + - include: main + interpolated_crystal: + - match: '#\{(\})' + scope: source.crystal.embedded.source + captures: + 0: punctuation.section.embedded.crystal + 1: source.crystal.embedded.source.empty + - match: '#\{' + captures: + 0: punctuation.section.embedded.crystal + push: + - meta_scope: source.crystal.embedded.source + - match: '\}' + captures: + 0: punctuation.section.embedded.crystal + pop: true + - include: nest_curly_and_self + - include: main + - match: '(#@)[a-zA-Z_]\w*' + scope: variable.other.readwrite.instance.crystal + captures: + 1: punctuation.definition.variable.crystal + - match: '(#@@)[a-zA-Z_]\w*' + scope: variable.other.readwrite.class.crystal + captures: + 1: punctuation.definition.variable.crystal + - match: '(#\$)[a-zA-Z_]\w*' + scope: variable.other.readwrite.global.crystal + captures: + 1: punctuation.definition.variable.crystal + nest_brackets: + - match: '\[' + captures: + 0: punctuation.section.scope.crystal + push: + - match: '\]' + captures: + 0: punctuation.section.scope.crystal + pop: true + - include: nest_brackets + nest_brackets_i: + - match: '\[' + captures: + 0: punctuation.section.scope.crystal + push: + - match: '\]' + captures: + 0: punctuation.section.scope.crystal + pop: true + - include: interpolated_crystal + - include: escaped_char + - include: nest_brackets_i + nest_brackets_r: + - match: '\[' + captures: + 0: punctuation.section.scope.crystal + push: + - match: '\]' + captures: + 0: punctuation.section.scope.crystal + pop: true + - include: regex_sub + - include: nest_brackets_r + nest_curly: + - match: '\{' + captures: + 0: punctuation.section.scope.crystal + push: + - match: '\}' + captures: + 0: punctuation.section.scope.crystal + pop: true + - include: nest_curly + nest_curly_and_self: + - match: '\{' + captures: + 0: punctuation.section.scope.crystal + push: + - match: '\}' + captures: + 0: punctuation.section.scope.crystal + pop: true + - include: nest_curly_and_self + - include: main + nest_curly_i: + - match: '\{' + captures: + 0: punctuation.section.scope.crystal + push: + - match: '\}' + captures: + 0: punctuation.section.scope.crystal + pop: true + - include: interpolated_crystal + - include: escaped_char + - include: nest_curly_i + nest_curly_r: + - match: '\{' + captures: + 0: punctuation.section.scope.crystal + push: + - match: '\}' + captures: + 0: punctuation.section.scope.crystal + pop: true + - include: regex_sub + - include: nest_curly_r + nest_ltgt: + - match: \< + captures: + 0: punctuation.section.scope.crystal + push: + - match: \> + captures: + 0: punctuation.section.scope.crystal + pop: true + - include: nest_ltgt + nest_ltgt_i: + - match: \< + captures: + 0: punctuation.section.scope.crystal + push: + - match: \> + captures: + 0: punctuation.section.scope.crystal + pop: true + - include: interpolated_crystal + - include: escaped_char + - include: nest_ltgt_i + nest_ltgt_r: + - match: \< + captures: + 0: punctuation.section.scope.crystal + push: + - match: \> + captures: + 0: punctuation.section.scope.crystal + pop: true + - include: regex_sub + - include: nest_ltgt_r + nest_parens: + - match: \( + captures: + 0: punctuation.section.scope.crystal + push: + - match: \) + captures: + 0: punctuation.section.scope.crystal + pop: true + - include: nest_parens + nest_parens_i: + - match: \( + captures: + 0: punctuation.section.scope.crystal + push: + - match: \) + captures: + 0: punctuation.section.scope.crystal + pop: true + - include: interpolated_crystal + - include: escaped_char + - include: nest_parens_i + nest_parens_r: + - match: \( + captures: + 0: punctuation.section.scope.crystal + push: + - match: \) + captures: + 0: punctuation.section.scope.crystal + pop: true + - include: regex_sub + - include: nest_parens_r + regex_sub: + - include: interpolated_crystal + - include: escaped_char + - match: '(\{)\d+(,\d+)?(\})' + scope: string.regexp.arbitrary-repitition.crystal + captures: + 1: punctuation.definition.arbitrary-repitition.crystal + 3: punctuation.definition.arbitrary-repitition.crystal + - match: '\[(?:\^?\])?' + captures: + 0: punctuation.definition.character-class.crystal + push: + - meta_scope: string.regexp.character-class.crystal + - match: '\]' + captures: + 0: punctuation.definition.character-class.crystal + pop: true + - include: escaped_char + - match: \( + captures: + 0: punctuation.definition.group.crystal + push: + - meta_scope: string.regexp.group.crystal + - match: \) + captures: + 0: punctuation.definition.group.crystal + pop: true + - include: regex_sub + - match: '(?<=^|\s)(#)\s[[a-zA-Z0-9,. \t?!-][^\x{00}-\x{7F}]]*$' + comment: We are restrictive in what we allow to go after the comment character to avoid false positives, since the availability of comments depend on regexp flags. + scope: comment.line.number-sign.crystal + captures: + 1: punctuation.definition.comment.crystal diff --git a/sublime_syntaxes/Elixir.sublime-syntax b/sublime_syntaxes/Elixir.sublime-syntax new file mode 100644 index 00000000..e2aa9711 --- /dev/null +++ b/sublime_syntaxes/Elixir.sublime-syntax @@ -0,0 +1,525 @@ +%YAML 1.2 +--- +# http://www.sublimetext.com/docs/3/syntax.html +name: Elixir +comment: Textmate bundle for Elixir Programming Language. +file_extensions: + - ex + - exs +first_line_match: ^#!/.*\belixir +scope: source.elixir +contexts: + main: + - match: \b(fn)\b(?!.*->) + captures: + 1: keyword.control.elixir + push: + - match: $ + pop: true + - include: core_syntax + - match: \b(fn)\b(?=.*->) + captures: + 1: keyword.control.elixir + push: + - match: (?>(->)|(when)|(\))) + captures: + 1: keyword.operator.other.elixir + 2: keyword.control.elixir + 3: punctuation.definition.parameters.elixir + pop: true + - include: core_syntax + - include: core_syntax + - match: '^(?=.*->)((?![^"'']*("|'')[^"'']*->)|(?=.*->[^"'']*("|'')[^"'']*->))((?!.*\([^\)]*->)|(?=[^\(\)]*->)|(?=\s*\(.*\).*->))((?!.*\b(fn)\b)|(?=.*->.*\bfn\b))' + captures: + 1: keyword.control.elixir + push: + - match: (?>(->)|(when)|(\))) + captures: + 1: keyword.operator.other.elixir + 2: keyword.control.elixir + 3: punctuation.definition.parameters.elixir + pop: true + - include: core_syntax + core_syntax: + - match: ^\s*(defmodule)\b + captures: + 1: keyword.control.module.elixir + push: + - meta_scope: meta.module.elixir + - match: \b(do)\b + captures: + 1: keyword.control.module.elixir + pop: true + - match: '\b[A-Z]\w*\b' + scope: entity.name.class.elixir + - match: ^\s*(defprotocol)\b + captures: + 1: keyword.control.protocol.elixir + push: + - meta_scope: meta.protocol_declaration.elixir + - match: \b(do)\b + captures: + 1: keyword.control.protocol.elixir + pop: true + - match: '\b[A-Z]\w*\b' + scope: entity.name.protocol.elixir + - match: ^\s*(defimpl)\b + captures: + 1: keyword.control.protocol.elixir + push: + - meta_scope: meta.protocol_implementation.elixir + - match: \b(do)\b + captures: + 1: keyword.control.protocol.elixir + pop: true + - match: '\b[A-Z]\w*\b' + scope: entity.name.protocol.elixir + - match: '^\s*(def|defmacro)\s+((?>[a-zA-Z_]\w*(?>\.|::))?(?>[a-zA-Z_]\w*(?>[?!]|=(?!>))?|===?|>[>=]?|<=>|<[<=]?|[%&`/\|]|\*\*?|=?~|[-+]@?|\[\]=?))((\()|\s*)' + captures: + 1: keyword.control.module.elixir + 2: entity.name.function.public.elixir + 4: punctuation.definition.parameters.elixir + push: + - meta_scope: meta.function.public.elixir + - match: (\bdo:)|(\bdo\b)|(?=\s+(def|defmacro)\b) + captures: + 1: constant.other.keywords.elixir + 2: keyword.control.module.elixir + pop: true + - include: main + - match: \s(\\\\) + captures: + 1: keyword.operator.other.elixir + push: + - match: ',|\)|$' + pop: true + - include: main + - match: \b(is_atom|is_binary|is_bitstring|is_boolean|is_float|is_function|is_integer|is_list|is_map|is_nil|is_number|is_pid|is_port|is_record|is_reference|is_tuple|is_exception|abs|bit_size|byte_size|div|elem|hd|length|map_size|node|rem|round|tl|trunc|tuple_size)\b + scope: keyword.control.elixir + - match: '^\s*(defp|defmacrop)\s+((?>[a-zA-Z_]\w*(?>\.|::))?(?>[a-zA-Z_]\w*(?>[?!]|=(?!>))?|===?|>[>=]?|<=>|<[<=]?|[%&`/\|]|\*\*?|=?~|[-+]@?|\[\]=?))((\()|\s*)' + captures: + 1: keyword.control.module.elixir + 2: entity.name.function.private.elixir + 4: punctuation.definition.parameters.elixir + push: + - meta_scope: meta.function.private.elixir + - match: (\bdo:)|(\bdo\b)|(?=\s+(defp|defmacrop)\b) + captures: + 1: constant.other.keywords.elixir + 2: keyword.control.module.elixir + pop: true + - include: main + - match: \s(\\\\) + captures: + 1: keyword.operator.other.elixir + push: + - match: ',|\)|$' + pop: true + - include: main + - match: \b(is_atom|is_binary|is_bitstring|is_boolean|is_float|is_function|is_integer|is_list|is_map|is_nil|is_number|is_pid|is_port|is_record|is_reference|is_tuple|is_exception|abs|bit_size|byte_size|div|elem|hd|length|map_size|node|rem|round|tl|trunc|tuple_size)\b + scope: keyword.control.elixir + - match: '@(module|type)?doc (~[a-z])?"""' + comment: "@doc with heredocs is treated as documentation" + push: + - meta_scope: comment.documentation.heredoc + - match: \s*""" + pop: true + - include: interpolated_elixir + - include: escaped_char + - match: '@(module|type)?doc ~[A-Z]"""' + comment: "@doc with heredocs is treated as documentation" + push: + - meta_scope: comment.documentation.heredoc + - match: \s*""" + pop: true + - match: "@(module|type)?doc (~[a-z])?'''" + comment: "@doc with heredocs is treated as documentation" + push: + - meta_scope: comment.documentation.heredoc + - match: \s*''' + pop: true + - include: interpolated_elixir + - include: escaped_char + - match: "@(module|type)?doc ~[A-Z]'''" + comment: "@doc with heredocs is treated as documentation" + push: + - meta_scope: comment.documentation.heredoc + - match: \s*''' + pop: true + - match: "@(module|type)?doc false" + comment: "@doc false is treated as documentation" + scope: comment.documentation.false + - match: '@(module|type)?doc "' + comment: "@doc with string is treated as documentation" + push: + - meta_scope: comment.documentation.string + - match: '"' + pop: true + - include: interpolated_elixir + - include: escaped_char + - match: (::) + captures: + 0: punctuation.binary.elixir + push: + - match: (,|>>|$) + captures: + 0: punctuation.binary.elixir + pop: true + - match: '\b[a-z]\w*\b' + scope: support.type.binary.elixir + - match: '\b(0x[0-9A-Fa-f](?>_?[0-9A-Fa-f])*|\d(?>_?\d)*(\.(?![^[:space:][:digit:]])(?>_?\d)*)?([eE][-+]?\d(?>_?\d)*)?|0b[01]+|0o[0-7]+)\b' + scope: constant.numeric.elixir + - match: '(?_?[0-9A-Fa-f])*|\d(?>_?\d)*(\.(?![^[:space:][:digit:]])(?>_?\d)*)?([eE][-+]?\d(?>_?\d)*)?|0b[01]+|0o[0-7]+)\b' + scope: constant.numeric.elixir + - match: ":'" + captures: + 0: punctuation.definition.constant.elixir + push: + - meta_scope: constant.other.symbol.single-quoted.elixir + - match: "'" + captures: + 0: punctuation.definition.constant.elixir + pop: true + - include: interpolated_elixir + - include: escaped_char + - match: ':"' + captures: + 0: punctuation.definition.constant.elixir + push: + - meta_scope: constant.other.symbol.double-quoted.elixir + - match: '"' + captures: + 0: punctuation.definition.constant.elixir + pop: true + - include: interpolated_elixir + - include: escaped_char + - match: (?>''') + comment: Single-quoted heredocs + captures: + 0: punctuation.definition.string.begin.elixir + push: + - meta_scope: string.quoted.single.heredoc.elixir + - match: ^\s*''' + captures: + 0: punctuation.definition.string.end.elixir + pop: true + - include: interpolated_elixir + - include: escaped_char + - match: "'" + comment: single quoted string (allows for interpolation) + captures: + 0: punctuation.definition.string.begin.elixir + push: + - meta_scope: string.quoted.single.elixir + - match: "'" + captures: + 0: punctuation.definition.string.end.elixir + pop: true + - include: interpolated_elixir + - include: escaped_char + - match: (?>""") + comment: Double-quoted heredocs + captures: + 0: punctuation.definition.string.begin.elixir + push: + - meta_scope: string.quoted.double.heredoc.elixir + - match: ^\s*""" + captures: + 0: punctuation.definition.string.end.elixir + pop: true + - include: interpolated_elixir + - include: escaped_char + - match: '"' + comment: double quoted string (allows for interpolation) + captures: + 0: punctuation.definition.string.begin.elixir + push: + - meta_scope: string.quoted.double.elixir + - match: '"' + captures: + 0: punctuation.definition.string.end.elixir + pop: true + - include: interpolated_elixir + - include: escaped_char + - match: '~[a-z](?>""")' + comment: Double-quoted heredocs sigils + captures: + 0: punctuation.definition.string.begin.elixir + push: + - meta_scope: string.quoted.double.heredoc.elixir + - match: ^\s*""" + captures: + 0: punctuation.definition.string.end.elixir + pop: true + - include: interpolated_elixir + - include: escaped_char + - match: '~[a-z]\{' + comment: sigil (allow for interpolation) + captures: + 0: punctuation.definition.string.begin.elixir + push: + - meta_scope: string.interpolated.elixir + - match: '\}[a-z]*' + captures: + 0: punctuation.definition.string.end.elixir + pop: true + - include: interpolated_elixir + - include: escaped_char + - match: '~[a-z]\[' + comment: sigil (allow for interpolation) + captures: + 0: punctuation.definition.string.begin.elixir + push: + - meta_scope: string.interpolated.elixir + - match: '\][a-z]*' + captures: + 0: punctuation.definition.string.end.elixir + pop: true + - include: interpolated_elixir + - include: escaped_char + - match: '~[a-z]\<' + comment: sigil (allow for interpolation) + captures: + 0: punctuation.definition.string.begin.elixir + push: + - meta_scope: string.interpolated.elixir + - match: '\>[a-z]*' + captures: + 0: punctuation.definition.string.end.elixir + pop: true + - include: interpolated_elixir + - include: escaped_char + - match: '~[a-z]\(' + comment: sigil (allow for interpolation) + captures: + 0: punctuation.definition.string.begin.elixir + push: + - meta_scope: string.interpolated.elixir + - match: '\)[a-z]*' + captures: + 0: punctuation.definition.string.end.elixir + pop: true + - include: interpolated_elixir + - include: escaped_char + - match: '~[a-z]([^\w])' + comment: sigil (allow for interpolation) + captures: + 0: punctuation.definition.string.begin.elixir + push: + - meta_scope: string.interpolated.elixir + - match: '\1[a-z]*' + captures: + 0: punctuation.definition.string.end.elixir + pop: true + - include: interpolated_elixir + - include: escaped_char + - include: escaped_char + - match: '~[A-Z](?>""")' + comment: Double-quoted heredocs sigils + captures: + 0: punctuation.definition.string.begin.elixir + push: + - meta_scope: string.quoted.other.literal.upper.elixir + - match: ^\s*""" + captures: + 0: punctuation.definition.string.end.elixir + pop: true + - match: '~[A-Z]\{' + comment: sigil (without interpolation) + captures: + 0: punctuation.definition.string.begin.elixir + push: + - meta_scope: string.quoted.other.literal.upper.elixir + - match: '\}[a-z]*' + captures: + 0: punctuation.definition.string.end.elixir + pop: true + - match: '~[A-Z]\[' + comment: sigil (without interpolation) + captures: + 0: punctuation.definition.string.begin.elixir + push: + - meta_scope: string.quoted.other.literal.upper.elixir + - match: '\][a-z]*' + captures: + 0: punctuation.definition.string.end.elixir + pop: true + - match: '~[A-Z]\<' + comment: sigil (without interpolation) + captures: + 0: punctuation.definition.string.begin.elixir + push: + - meta_scope: string.quoted.other.literal.upper.elixir + - match: '\>[a-z]*' + captures: + 0: punctuation.definition.string.end.elixir + pop: true + - match: '~[A-Z]\(' + comment: sigil (without interpolation) + captures: + 0: punctuation.definition.string.begin.elixir + push: + - meta_scope: string.quoted.other.literal.upper.elixir + - match: '\)[a-z]*' + captures: + 0: punctuation.definition.string.end.elixir + pop: true + - match: '~[A-Z]([^\w])' + comment: sigil (without interpolation) + captures: + 0: punctuation.definition.string.begin.elixir + push: + - meta_scope: string.quoted.other.literal.upper.elixir + - match: '\1[a-z]*' + captures: + 0: punctuation.definition.string.end.elixir + pop: true + - match: '(?[a-zA-Z_][\w@]*(?>[?!]|=(?![>=]))?|\<\>|===?|!==?|<<>>|<<<|>>>|~~~|::|<\-|\|>|=>|=~|=|/|\\\\|\*\*?|\.\.?\.?|>=?|<=?|&&?&?|\+\+?|\-\-?|\|\|?\|?|\!|@|\%?\{\}|%|\[\]|\^(\^\^)?)' + comment: symbols + scope: constant.other.symbol.elixir + captures: + 1: punctuation.definition.constant.elixir + - match: '(?>[a-zA-Z_][\w@]*(?>[?!])?)(:)(?!:)' + comment: symbols + scope: constant.other.keywords.elixir + captures: + 1: punctuation.definition.constant.elixir + - match: ^\s*(##).*$\n? + scope: comment.line.section.elixir + captures: + 1: punctuation.definition.comment.elixir + - match: '(?:^[ \t]+)?(#).*$\n?' + scope: comment.line.number-sign.elixir + captures: + 1: punctuation.definition.comment.elixir + - match: '(?=?" + scope: keyword.operator.comparison.elixir + - match: (\|\|\||&&&|^^^|<<<|>>>|~~~) + scope: keyword.operator.bitwise.elixir + - match: '(?<=[ \t])!+|\bnot\b|&&|\band\b|\|\||\bor\b|\bxor\b' + scope: keyword.operator.logical.elixir + - match: (\*|\+|\-|/) + scope: keyword.operator.arithmetic.elixir + - match: \||\+\+|\-\-|\*\*|\\\\|\<\-|\<\>|\<\<|\>\>|\:\:|\.\.|\|>|~|=>|& + scope: keyword.operator.other.elixir + - match: "=" + scope: keyword.operator.assignment.elixir + - match: ":" + scope: punctuation.separator.other.elixir + - match: \; + scope: punctuation.separator.statement.elixir + - match: "," + scope: punctuation.separator.object.elixir + - match: \. + scope: punctuation.separator.method.elixir + - match: '\{|\}' + scope: punctuation.section.scope.elixir + - match: '\[|\]' + scope: punctuation.section.array.elixir + - match: \(|\) + scope: punctuation.section.function.elixir + escaped_char: + - match: '\\(x[\da-fA-F]{1,2}|.)' + scope: constant.character.escaped.elixir + interpolated_elixir: + - match: '#\{(\})' + scope: source.elixir.embedded.source + captures: + 0: punctuation.section.embedded.elixir + 1: source.elixir.embedded.source.empty + - match: '#\{' + captures: + 0: punctuation.section.embedded.elixir + push: + - meta_scope: source.elixir.embedded.source + - match: '\}' + captures: + 0: punctuation.section.embedded.elixir + pop: true + - include: nest_curly_and_self + - include: main + nest_curly_and_self: + - match: '\{' + captures: + 0: punctuation.section.scope.elixir + push: + - match: '\}' + captures: + 0: punctuation.section.scope.elixir + pop: true + - include: nest_curly_and_self + - include: main + regex_sub: + - include: interpolated_elixir + - include: escaped_char + - match: '(\{)\d+(,\d+)?(\})' + scope: string.regexp.arbitrary-repitition.elixir + captures: + 1: punctuation.definition.arbitrary-repitition.elixir + 3: punctuation.definition.arbitrary-repitition.elixir + - match: '\[(?:\^?\])?' + captures: + 0: punctuation.definition.character-class.elixir + push: + - meta_scope: string.regexp.character-class.elixir + - match: '\]' + captures: + 0: punctuation.definition.character-class.elixir + pop: true + - include: escaped_char + - match: \( + captures: + 0: punctuation.definition.group.elixir + push: + - meta_scope: string.regexp.group.elixir + - match: \) + captures: + 0: punctuation.definition.group.elixir + pop: true + - include: regex_sub + - match: '(?<=^|\s)(#)\s[[a-zA-Z0-9,. \t?!-][^\x{00}-\x{7F}]]*$' + comment: We are restrictive in what we allow to go after the comment character to avoid false positives, since the availability of comments depend on regexp flags. + scope: comment.line.number-sign.elixir + captures: + 1: punctuation.definition.comment.elixir diff --git a/sublime_syntaxes/Kotlin.sublime-syntax b/sublime_syntaxes/Kotlin.sublime-syntax new file mode 100644 index 00000000..6593e9d0 --- /dev/null +++ b/sublime_syntaxes/Kotlin.sublime-syntax @@ -0,0 +1,389 @@ +%YAML 1.2 +--- +# http://www.sublimetext.com/docs/3/syntax.html +name: Kotlin +file_extensions: + - kt + - kts +scope: source.Kotlin +contexts: + main: + - include: comments + - match: '^\s*(package)\b(?:\s*([^ ;$]+)\s*)?' + captures: + 1: keyword.other.kotlin + 2: entity.name.package.kotlin + - include: imports + - include: statements + classes: + - match: (?=\s*(?:companion|class|object|interface)) + push: + - match: "}|(?=$)" + pop: true + - match: \b(companion\s*)?(class|object|interface)\b + captures: + 1: keyword.other.kotlin + push: + - match: '(?=<|{|\(|:)' + pop: true + - match: \b(object)\b + scope: keyword.other.kotlin + - match: \w+ + scope: entity.name.type.class.kotlin + - match: < + push: + - match: ">" + pop: true + - include: generics + - match: \( + push: + - match: \) + pop: true + - include: parameters + - match: (:) + captures: + 1: keyword.operator.declaration.kotlin + push: + - match: "(?={|$)" + pop: true + - match: \w+ + scope: entity.other.inherited-class.kotlin + - match: \( + push: + - match: \) + pop: true + - include: expressions + - match: '\{' + push: + - match: '\}' + pop: true + - include: statements + comments: + - match: /\* + captures: + 0: punctuation.definition.comment.kotlin + push: + - meta_scope: comment.block.kotlin + - match: \*/ + captures: + 0: punctuation.definition.comment.kotlin + pop: true + - match: \s*((//).*$\n?) + captures: + 1: comment.line.double-slash.kotlin + 2: punctuation.definition.comment.kotlin + constants: + - match: \b(true|false|null|this|super)\b + scope: constant.language.kotlin + - match: '\b((0(x|X)[0-9a-fA-F]*)|(([0-9]+\.?[0-9]*)|(\.[0-9]+))((e|E)(\+|-)?[0-9]+)?)([LlFfUuDd]|UL|ul)?\b' + scope: constant.numeric.kotlin + - match: '\b([A-Z][A-Z0-9_]+)\b' + scope: constant.other.kotlin + expressions: + - match: \( + push: + - match: \) + pop: true + - include: expressions + - include: types + - include: strings + - include: constants + - include: comments + - include: keywords + functions: + - match: (?=\s*(?:fun)) + push: + - match: "}|(?=$)" + pop: true + - match: \b(fun)\b + captures: + 1: keyword.other.kotlin + push: + - match: (?=\() + pop: true + - match: < + push: + - match: ">" + pop: true + - include: generics + - match: '([\.<\?>\w]+\.)?(\w+)' + captures: + 2: entity.name.function.kotlin + - match: \( + push: + - match: \) + pop: true + - include: parameters + - match: (:) + captures: + 1: keyword.operator.declaration.kotlin + push: + - match: "(?={|=|$)" + pop: true + - include: types + - match: '\{' + push: + - match: '(?=\})' + pop: true + - include: statements + - match: (=) + captures: + 1: keyword.operator.assignment.kotlin + push: + - match: (?=$) + pop: true + - include: expressions + generics: + - match: (:) + captures: + 1: keyword.operator.declaration.kotlin + push: + - match: (?=,|>) + pop: true + - include: types + - include: keywords + - match: \w+ + scope: storage.type.generic.kotlin + getters-and-setters: + - match: \b(get)\b\s*\(\s*\) + captures: + 1: entity.name.function.kotlin + push: + - match: '\}|(?=\bset\b)|$' + pop: true + - match: (=) + captures: + 1: keyword.operator.assignment.kotlin + push: + - match: (?=$|\bset\b) + pop: true + - include: expressions + - match: '\{' + push: + - match: '\}' + pop: true + - include: expressions + - match: \b(set)\b\s*(?=\() + captures: + 1: entity.name.function.kotlin + push: + - match: '\}|(?=\bget\b)|$' + pop: true + - match: \( + push: + - match: \) + pop: true + - include: parameters + - match: (=) + captures: + 1: keyword.operator.assignment.kotlin + push: + - match: (?=$|\bset\b) + pop: true + - include: expressions + - match: '\{' + push: + - match: '\}' + pop: true + - include: expressions + imports: + - match: '^\s*(import)\s+[^ $]+\s+(as)?' + captures: + 1: keyword.other.kotlin + 2: keyword.other.kotlin + keywords: + - match: \b(var|val|public|private|protected|abstract|final|enum|open|attribute|annotation|override|inline|var|val|vararg|lazy|in|out|internal|data|tailrec|operator|infix|const|yield|typealias|typeof)\b + scope: storage.modifier.kotlin + - match: \b(try|catch|finally|throw)\b + scope: keyword.control.catch-exception.kotlin + - match: \b(if|else|while|for|do|return|when|where|break|continue)\b + scope: keyword.control.kotlin + - match: \b(in|is|as|assert)\b + scope: keyword.operator.kotlin + - match: (==|!=|===|!==|<=|>=|<|>) + scope: keyword.operator.comparison.kotlin + - match: (=) + scope: keyword.operator.assignment.kotlin + - match: (:) + scope: keyword.operator.declaration.kotlin + - match: (\.) + scope: keyword.operator.dot.kotlin + - match: (\-\-|\+\+) + scope: keyword.operator.increment-decrement.kotlin + - match: (\-|\+|\*|\/|%) + scope: keyword.operator.arithmetic.kotlin + - match: (\+=|\-=|\*=|\/=) + scope: keyword.operator.arithmetic.assign.kotlin + - match: (!|&&|\|\|) + scope: keyword.operator.logical.kotlin + - match: (\.\.) + scope: keyword.operator.range.kotlin + - match: (;) + scope: punctuation.terminator.kotlin + namespaces: + - match: \b(namespace)\b + scope: keyword.other.kotlin + - match: '\{' + push: + - match: '\}' + pop: true + - include: statements + parameters: + - match: (:) + captures: + 1: keyword.operator.declaration.kotlin + push: + - match: (?=,|\)|=) + pop: true + - include: types + - match: (=) + captures: + 1: keyword.operator.declaration.kotlin + push: + - match: (?=,|\)) + pop: true + - include: expressions + - include: keywords + - match: \w+ + scope: variable.parameter.function.kotlin + statements: + - include: namespaces + - include: typedefs + - include: classes + - include: functions + - include: variables + - include: getters-and-setters + - include: expressions + strings: + - match: '"""' + captures: + 0: punctuation.definition.string.begin.kotlin + push: + - meta_scope: string.quoted.third.kotlin + - match: '"""' + captures: + 0: punctuation.definition.string.end.kotlin + pop: true + - match: '(\$\w+|\$\{[^\}]+\})' + scope: variable.parameter.template.kotlin + - match: \\. + scope: constant.character.escape.kotlin + - match: '"' + captures: + 0: punctuation.definition.string.begin.kotlin + push: + - meta_scope: string.quoted.double.kotlin + - match: '"' + captures: + 0: punctuation.definition.string.end.kotlin + pop: true + - match: '(\$\w+|\$\{[^\}]+\})' + scope: variable.parameter.template.kotlin + - match: \\. + scope: constant.character.escape.kotlin + - match: "'" + captures: + 0: punctuation.definition.string.begin.kotlin + push: + - meta_scope: string.quoted.single.kotlin + - match: "'" + captures: + 0: punctuation.definition.string.end.kotlin + pop: true + - match: \\. + scope: constant.character.escape.kotlin + - match: "`" + captures: + 0: punctuation.definition.string.begin.kotlin + push: + - meta_scope: string.quoted.single.kotlin + - match: "`" + captures: + 0: punctuation.definition.string.end.kotlin + pop: true + typedefs: + - match: (?=\s*(?:type)) + push: + - match: (?=$) + pop: true + - match: \b(type)\b + scope: keyword.other.kotlin + - match: < + push: + - match: ">" + pop: true + - include: generics + - include: expressions + types: + - match: \b(Any|Unit|String|Int|Boolean|Char|Long|Double|Float|Short|Byte|dynamic)\b + scope: storage.type.buildin.kotlin + - match: \b(IntArray|BooleanArray|CharArray|LongArray|DoubleArray|FloatArray|ShortArray|ByteArray)\b + scope: storage.type.buildin.array.kotlin + - match: \b(Array|List|Map)<\b + captures: + 1: storage.type.buildin.collection.kotlin + push: + - match: ">" + pop: true + - include: types + - include: keywords + - match: \w+< + push: + - match: ">" + pop: true + - include: types + - include: keywords + - match: (#)\( + captures: + 1: keyword.operator.tuple.kotlin + push: + - match: \) + pop: true + - include: expressions + - match: '\{' + push: + - match: '\}' + pop: true + - include: statements + - match: \( + push: + - match: \) + pop: true + - include: types + - match: (->) + scope: keyword.operator.declaration.kotlin + variables: + - match: (?=\s*(?:var|val)) + push: + - match: (?=:|=|$) + pop: true + - match: \b(var|val)\b + captures: + 1: keyword.other.kotlin + push: + - match: (?=:|=|$) + pop: true + - match: < + push: + - match: ">" + pop: true + - include: generics + - match: '([\.<\?>\w]+\.)?(\w+)' + captures: + 2: entity.name.variable.kotlin + - match: (:) + captures: + 1: keyword.operator.declaration.kotlin + push: + - match: (?==|$) + pop: true + - include: types + - include: getters-and-setters + - match: (=) + captures: + 1: keyword.operator.assignment.kotlin + push: + - match: (?=$) + pop: true + - include: expressions + - include: getters-and-setters diff --git a/sublime_syntaxes/Packages b/sublime_syntaxes/Packages index 1b206784..928a7a61 160000 --- a/sublime_syntaxes/Packages +++ b/sublime_syntaxes/Packages @@ -1 +1 @@ -Subproject commit 1b2067847ab557d74f41685eace343354dc2c198 +Subproject commit 928a7a618d99631ea424c45e74fb01d1fb6f6853 diff --git a/sublime_syntaxes/TypeScript-Sublime-Plugin b/sublime_syntaxes/TypeScript-Sublime-Plugin index eb57cebd..79bf8ddf 160000 --- a/sublime_syntaxes/TypeScript-Sublime-Plugin +++ b/sublime_syntaxes/TypeScript-Sublime-Plugin @@ -1 +1 @@ -Subproject commit eb57cebd62d0c2ea2c17d222c8c1c3cefa40f31b +Subproject commit 79bf8ddfb8a05a2b104f3937cd91b6f2afbbb943 diff --git a/sublime_syntaxes/newlines.packdump b/sublime_syntaxes/newlines.packdump index 52f851c3..809a8909 100644 Binary files a/sublime_syntaxes/newlines.packdump and b/sublime_syntaxes/newlines.packdump differ diff --git a/sublime_syntaxes/nonewlines.packdump b/sublime_syntaxes/nonewlines.packdump index 13aa7c0b..e469cbae 100644 Binary files a/sublime_syntaxes/nonewlines.packdump and b/sublime_syntaxes/nonewlines.packdump differ