tm-grammars
Version:
Collecton of TextMate grammars in JSON
530 lines (529 loc) • 11.4 kB
JSON
{
"displayName": "R",
"fileTypes": [
"R",
"r",
"Rprofile"
],
"foldingStartMarker": "\\{\\s*(?:#|$)",
"foldingStopMarker": "^\\s*}",
"name": "r",
"patterns": [
{
"include": "#roxygen-example"
},
{
"include": "#basic"
}
],
"repository": {
"basic": {
"patterns": [
{
"include": "#roxygen"
},
{
"include": "#comment"
},
{
"include": "#expression"
}
]
},
"basic-roxygen-example": {
"patterns": [
{
"match": "^\\s*#+'",
"name": "comment.line"
},
{
"include": "#comment"
},
{
"include": "#expression"
}
]
},
"brackets": {
"patterns": [
{
"begin": "\\{",
"end": "}",
"name": "meta.bracket",
"patterns": [
{
"include": "#basic"
}
]
},
{
"begin": "\\[",
"end": "]",
"name": "meta.bracket",
"patterns": [
{
"captures": {
"1": {
"name": "variable.parameter"
}
},
"match": "([.\\w]+)\\s*(?==[^=])"
},
{
"include": "#basic"
}
]
},
{
"begin": "\\(",
"end": "\\)",
"name": "meta.bracket",
"patterns": [
{
"captures": {
"1": {
"name": "variable.parameter"
}
},
"match": "([.\\w]+)\\s*(?==[^=])"
},
{
"include": "#basic"
}
]
}
]
},
"comment": {
"match": "#.*",
"name": "comment.line"
},
"escape-code": {
"match": "\\\\[\"'\\\\`abefnrtv]",
"name": "constant.character.escape"
},
"escape-hex": {
"match": "\\\\x\\h+",
"name": "constant.numeric"
},
"escape-invalid": {
"match": "\\\\.",
"name": "invalid"
},
"escape-octal": {
"match": "\\\\\\d{1,3}",
"name": "constant.character.escape"
},
"escape-unicode": {
"match": "\\\\[Uu](?:\\h+|\\{\\h+})",
"name": "constant.character.escape"
},
"escapes": {
"patterns": [
{
"include": "#escape-code"
},
{
"include": "#escape-hex"
},
{
"include": "#escape-octal"
},
{
"include": "#escape-unicode"
},
{
"include": "#escape-invalid"
}
]
},
"expression": {
"patterns": [
{
"include": "#brackets"
},
{
"include": "#raw-strings"
},
{
"include": "#strings"
},
{
"include": "#function-definition"
},
{
"include": "#keywords"
},
{
"include": "#function-call"
},
{
"include": "#identifiers"
},
{
"include": "#numbers"
},
{
"include": "#operators"
}
]
},
"function-call": {
"captures": {
"0": {
"name": "meta.function-call"
},
"1": {
"name": "entity.name.function"
}
},
"match": "([.\\w]+)(?=\\()"
},
"function-definition": {
"begin": "(function)\\s*(\\()",
"beginCaptures": {
"1": {
"name": "keyword.other"
},
"2": {
"name": "meta.bracket"
}
},
"end": "(\\))",
"endCaptures": {
"1": {
"name": "meta.bracket"
}
},
"name": "meta.function.definition",
"patterns": [
{
"begin": "([.\\w]+)",
"beginCaptures": {
"1": {
"name": "variable.parameter"
}
},
"end": "(?=[),])",
"patterns": [
{
"include": "#basic"
}
]
},
{
"include": "#basic"
}
]
},
"identifier-quoted": {
"begin": "`",
"end": "`",
"name": "variable.object",
"patterns": [
{
"match": "\\\\`"
}
]
},
"identifier-syntactic": {
"match": "[.\\p{L}\\p{Nl}][.\\p{L}\\p{Nl}\\p{Mn}\\p{Mc}\\d\\p{Pc}]*",
"name": "variable.object"
},
"identifiers": {
"patterns": [
{
"include": "#identifier-syntactic"
},
{
"include": "#identifier-quoted"
}
]
},
"keywords": {
"patterns": [
{
"include": "#keywords-control"
},
{
"include": "#keywords-builtin"
},
{
"include": "#keywords-constant"
}
]
},
"keywords-builtin": {
"match": "(?:setGroupGeneric|setRefClass|setGeneric|NextMethod|setMethod|UseMethod|tryCatch|setClass|warning|require|library|R6Class|return|switch|attach|detach|source|stop|try)(?=\\()",
"name": "keyword.other"
},
"keywords-constant": {
"match": "(?:NA_character_|NA_integer_|NA_complex_|NA_real_|TRUE|FALSE|NULL|Inf|NaN|NA)\\b",
"name": "constant.language"
},
"keywords-control": {
"match": "(?:\\\\|function|if|else|in|break|next|repeat|for|while)\\b",
"name": "keyword"
},
"latex": {
"patterns": [
{
"match": "\\\\\\w+",
"name": "keyword.other"
}
]
},
"markdown": {
"patterns": [
{
"begin": "(`{3,})\\s*(.*)",
"beginCaptures": {
"1": {
"name": "comment.line"
},
"2": {
"name": "entity.name.section"
}
},
"end": "(\\1)",
"endCaptures": {
"1": {
"name": "comment.line"
}
},
"patterns": [
{
"match": "^\\s*#+'",
"name": "comment.line"
}
]
},
{
"captures": {
"1": {
"name": "meta.bracket"
},
"2": {
"name": "variable.object"
},
"3": {
"name": "keyword.operator"
},
"4": {
"name": "entity.name.function"
},
"5": {
"name": "meta.bracket"
},
"6": {
"name": "meta.bracket"
}
},
"match": "(\\[)(?:(\\w+)(:{2,3}))?(\\w+)(\\(\\))?(])"
},
{
"match": "(\\s+|^)(__.+?__)\\b",
"name": "markdown.bold"
},
{
"match": "(\\s+|^)(_(?=[^_])(?:\\\\.|[^\\\\_])*?_)\\b",
"name": "markdown.italic"
},
{
"match": "(\\*\\*.+?\\*\\*)",
"name": "markdown.bold"
},
{
"match": "(\\*(?=[^*\\s])(?:\\\\.|[^*\\\\])*?\\*)",
"name": "markdown.italic"
},
{
"match": "(`(?:[^\\\\`]|\\\\.)*`)",
"name": "markup.quote"
},
{
"match": "(<)([^>]*)(>)",
"name": "markup.underline.link"
}
]
},
"numbers": {
"patterns": [
{
"match": "0[Xx]\\h+(?:p[-+]?\\d+)?[Li]?",
"name": "constant.numeric"
},
{
"match": "(?:\\d+(?:\\.\\d*)?|\\.\\d+)(?:[Ee][-+]?\\d*)?[Li]?",
"name": "constant.numeric"
}
]
},
"operators": {
"match": "%.*?%|:::?|:=|\\|>|=>|%%|>=|<=|==|!=|<<-|->>?|<-|\\|\\||&&|[-+=]|\\*\\*?|[!$\\&,/:<>?@^|~]",
"name": "keyword.operator"
},
"qqstring": {
"begin": "\"",
"end": "\"",
"name": "string.quoted.double",
"patterns": [
{
"include": "#escapes"
}
]
},
"qstring": {
"begin": "'",
"end": "'",
"name": "string.quoted.single",
"patterns": [
{
"include": "#escapes"
}
]
},
"raw-strings": {
"name": "string.quoted.other",
"patterns": [
{
"begin": "[Rr]\"(-*)\\{",
"end": "}\\1\"",
"name": "string.quoted.other"
},
{
"begin": "[Rr]'(-*)\\{",
"end": "}\\1'",
"name": "string.quoted.other"
},
{
"begin": "[Rr]\"(-*)\\[",
"end": "]\\1\"",
"name": "string.quoted.other"
},
{
"begin": "[Rr]'(-*)\\[",
"end": "]\\1'",
"name": "string.quoted.other"
},
{
"begin": "[Rr]\"(-*)\\(",
"end": "\\)\\1\"",
"name": "string.quoted.other"
},
{
"begin": "[Rr]'(-*)\\(",
"end": "\\)\\1'",
"name": "string.quoted.other"
}
]
},
"roxygen": {
"begin": "^(\\s*#+')",
"beginCaptures": {
"1": {
"name": "comment.line.roxygen"
}
},
"end": "$",
"patterns": [
{
"include": "#markdown"
},
{
"include": "#roxygen-tokens"
},
{
"include": "#latex"
},
{
"match": ".",
"name": "comment.line"
}
]
},
"roxygen-example": {
"begin": "^(\\s*#+')\\s*(?:(@examples)\\s*|(@examplesIf)\\s+(.*))$",
"beginCaptures": {
"1": {
"name": "comment.line"
},
"2": {
"name": "keyword.other"
},
"3": {
"name": "keyword.other"
},
"4": {
"patterns": [
{
"include": "#expression"
}
]
}
},
"end": "^(?:\\s*(?=#+'\\s*@)|\\s*(?!#+'))",
"patterns": [
{
"match": "^\\s*#+'",
"name": "comment.line"
},
{
"match": "[]()\\[{}]",
"name": "meta.bracket"
},
{
"include": "#latex"
},
{
"include": "#roxygen-tokens"
},
{
"include": "#basic-roxygen-example"
}
]
},
"roxygen-tokens": {
"patterns": [
{
"match": "@@",
"name": "constant.character.escape"
},
{
"begin": "(@(?:param|field|slot))\\s*",
"beginCaptures": {
"1": {
"name": "keyword.other"
}
},
"end": "\\s|$",
"patterns": [
{
"match": "([.\\w]+)",
"name": "variable.parameter"
},
{
"match": ",",
"name": "keyword.operator"
}
]
},
{
"match": "@(?!@)\\w*",
"name": "keyword.other"
}
]
},
"strings": {
"patterns": [
{
"include": "#qstring"
},
{
"include": "#qqstring"
}
]
}
},
"scopeName": "source.r"
}