%YAML 1.2 --- # http://www.sublimetext.com/docs/3/syntax.html name: R file_extensions: - R - r - s - S - Rprofile scope: source.r variables: var: '[a-zA-Z._][a-zA-Z0-9._]*' contexts: main: - include: roxygen - include: comments - include: constants - include: keywords - include: storage-types - include: strings - include: brackets - include: function-declarations - include: lambda-functions - include: builtin-functions - include: function-calls - include: general-variables comments: - match: "#" scope: punctuation.definition.comment.r push: - meta_scope: comment.line.number-sign.r - match: \n pop: true constants: - match: \b(pi|letters|LETTERS|month\.abb|month\.name)\b scope: support.constant.misc.r - match: \b(TRUE|FALSE|NULL|NA|NA_integer_|NA_real_|NA_complex_|NA_character_|Inf|NaN)\b scope: constant.language.r - match: \b0(x|X)[0-9a-fA-F]+i\b scope: constant.numeric.imaginary.hexadecimal.r - match: \b[0-9]+\.?[0-9]*(?:(e|E)(\+|-)?[0-9]+)?i\b scope: constant.numeric.imaginary.decimal.r - match: \.[0-9]+(?:(e|E)(\+|-)?[0-9]+)?i\b scope: constant.numeric.imaginary.decimal.r - match: \b0(x|X)[0-9a-fA-F]+L\b scope: constant.numeric.integer.hexadecimal.r - match: \b(?:[0-9]+\.?[0-9]*)L\b scope: constant.numeric.integer.decimal.r - match: \b0(x|X)[0-9a-fA-F]+\b scope: constant.numeric.float.hexadecimal.r - match: \b[0-9]+\.?[0-9]*(?:(e|E)(\+|-)?[0-9]+)?\b scope: constant.numeric.float.decimal.r - match: \.[0-9]+(?:(e|E)(\+|-)?[0-9]+)?\b scope: constant.numeric.float.decimal.r general-variables: - match: '{{var}}' keywords: - match: \b(break|next|repeat|else|in)\b scope: keyword.control.r - match: \b(ifelse|if|for|return|switch|while|invisible)\b(?=\s*\() scope: keyword.control.r - match: (\-|\+|\*|\/|%\/%|%%|%\*%|%o%|%x%|\^) scope: keyword.operator.arithmetic.r - match: (=|<-|<<-|->|->>) scope: keyword.operator.assignment.r - match: (==|!=|<>|<|>|<=|>=) scope: keyword.operator.comparison.r - match: (!|&{1,2}|[|]{1,2}) scope: keyword.operator.logical.r - match: (%in%|:=|%between%|%chin%|%like%|%\+%|%\+replace%|%:%|%do%|%dopar%|%>%|%<>%|%T>%|%\$%) scope: keyword.operator.other.r - match: (\.\.\.|\$|:|\~|@) scope: keyword.other.r storage-types: - match: \b(character|complex|double|expression|integer|list|logical|numeric|single|raw)\b(\s*\() captures: 1: storage.type.r push: function-parameters strings: - match: '"' scope: punctuation.definition.string.begin.r push: - meta_scope: string.quoted.double.r - match: \\. scope: constant.character.escape.r - match: '"' scope: punctuation.definition.string.end.r pop: true - match: "'" scope: punctuation.definition.string.begin.r push: - meta_scope: string.quoted.single.r - match: \\. scope: constant.character.escape.r - match: "'" scope: punctuation.definition.string.end.r pop: true brackets: - match: \( scope: punctuation.section.parens.begin.r push: - match: \) scope: punctuation.section.parens.end.r pop: true - include: main - match: \[(?!\[) scope: meta.item-access.r punctuation.section.brackets.single.begin.r push: - meta_content_scope: meta.item-access.r meta.item-access.arguments.r - match: \](?!\]) scope: meta.item-access.r punctuation.section.brackets.single.end.r pop: true - include: main - match: \[\[ scope: meta.item-access.r punctuation.section.brackets.double.begin.r push: - meta_content_scope: meta.item-access.r meta.item-access.arguments.r - match: \]\] scope: meta.item-access.r punctuation.section.brackets.double.end.r pop: true - include: main - match: \{ scope: punctuation.section.braces.begin.r push: - match: \} scope: punctuation.section.braces.end.r pop: true - include: main function-declarations: - match: ^\s*({{var}})\s*(<