Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

TextMate syntax highlighting for R with roxygen

View R-roxygen.tmLanguage
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
{ scopeName = 'source.r';
fileTypes = ( 'R', 'r', 's', 'S', 'Rprofile' );
foldingStartMarker = '^[^#]*(\([^\)]*$|\{\s*$)';
foldingStopMarker = '(^\s*\)|^\s*\})';
patterns = (
{ name = 'comment.line.number-sign.r';
match = "(#(?!').{1}).*$\n?";
captures = { 1 = { name = 'punctuation.definition.comment.r'; }; };
},
{ name = 'storage.type.r';
match = '\b(logical|numeric|character|complex|matrix|array|data\.frame|list|factor)(?=\s*\()';
},
{ name = 'keyword.control.r';
match = '\b(function|if|break|next|repeat|else|for|return|switch|while|in|invisible)\b';
},
{ name = 'constant.numeric.r';
match = '\b((0(x|X)[0-9a-fA-F]*)|(([0-9]+\.?[0-9]*)|(\.[0-9]+))((e|E)(\+|-)?[0-9]+)?)(i|L|l|UL|ul|u|U|F|f|ll|LL|ull|ULL)?\b';
},
{ name = 'constant.language.r';
match = '\b(T|F|TRUE|FALSE|NULL|NA|Inf|NaN)\b';
},
{ name = 'support.constant.misc.r';
match = '\b(pi|letters|LETTERS|month\.abb|month\.name)\b';
},
{ name = 'keyword.operator.arithmetic.r';
match = '(\-|\+|\*|\/|%\/%|%%|%\*%|%in%|%o%|%x%|\^)';
},
{ name = 'keyword.operator.assignment.r';
match = '(=|<-|<<-|->|->>)';
},
{ name = 'keyword.operator.comparison.r';
match = '(==|!=|<>|<|>|<=|>=)';
},
{ name = 'keyword.operator.logical.r';
match = '(!|&{1,2}|[|]{1,2})';
},
{ name = 'keyword.other.r';
match = '(\.\.\.|\$|@|:|\~)';
},
{ name = 'string.quoted.double.r';
begin = '"';
end = '"';
beginCaptures = { 0 = { name = 'punctuation.definition.string.begin.r'; }; };
endCaptures = { 0 = { name = 'punctuation.definition.string.end.r'; }; };
patterns = (
{ name = 'constant.character.escape.r';
match = '\\.';
},
);
},
{ name = 'string.quoted.single.r';
begin = "'";
end = "'";
beginCaptures = { 0 = { name = 'punctuation.definition.string.begin.r'; }; };
endCaptures = { 0 = { name = 'punctuation.definition.string.end.r'; }; };
patterns = (
{ name = 'constant.character.escape.r';
match = '\\.';
},
);
},
{ name = 'meta.function.r';
match = '([[:alpha:].][[:alnum:]._]*)\s*(<-)\s*(function)';
captures = {
1 = { name = 'entity.name.function.r'; };
2 = { name = 'keyword.operator.assignment.r'; };
3 = { name = 'keyword.control.r'; };
};
},
{ name = 'meta.method.declaration.r';
match = '(setMethod|setGeneric|setGroupGeneric|setClass)\s*\(\s*("|\x{27})([a-zA-Z._\[\$@][a-zA-Z0-9._\[]*?)\2';
captures = {
1 = { name = 'entity.name.tag.r'; };
3 = { name = 'entity.name.type.r'; };
};
},
{ match = '([[:alpha:].][[:alnum:]._]*)\s*\('; },
{ match = '([[:alpha:].][[:alnum:]._]*)\s*(=)(?=[^=])';
captures = {
1 = { name = 'variable.parameter.r'; };
2 = { name = 'keyword.operator.assignment.r'; };
};
},
{ name = 'invalid.illegal.variable.other.r';
match = '\b([\d_][[:alnum:]._]+)\b';
},
{ name = 'entity.name.type.namespace.r';
match = '\b([[:alnum:]_]+)(?=::)';
},
{ name = 'variable.other.r';
match = '\b([[:alnum:]._]+)\b';
},
{ name = 'meta.comment.roxygen';
contentName = 'source.r.embedded.roxygen';
begin = "#'";
end = '$';
beginCaptures = { 1 = { name = 'comment.block.documentation.roxygen'; }; };
endCaptures = { 1 = { name = 'comment.block.documentation.roxygen'; }; };
patterns = (
{ name = 'keyword.other.param.roxygen';
contentName = 'variable.other.param.roxygen';
begin = '\@param\s';
end = '\b\s';
},
{ name = 'keyword.other.roxygen';
begin = '\@\b';
end = '[[:space:]]';
},
{ name = 'comment.line.number-sign.r';
match = '(#).*$';
captures = { 1 = { name = 'punctuation.definition.comment.r'; }; };
},
{ include = 'text.tex.latex.rd'; },
);
},
);
}

This is just a quick hack, it doesn't yet work as well as I would like but it is better than nothing.

Must have the R bundle installed. Easiest way to install is to open the bundle editor ("Bundles" > "Bundle Editor" > "Show Bundle Editor") and copy this file over the R syntax file from the R bundle. Then "Reload Bundles" or restart TextMate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.