Skip to content
Snippets Groups Projects
Commit 8b4cea29 authored by Marijn Haverbeke's avatar Marijn Haverbeke
Browse files

Color named-argument '=' op differently in R mode

parent baf5ccc5
No related branches found
No related tags found
No related merge requests found
......@@ -10,7 +10,8 @@
.CodeMirror { border-top: 1px solid silver; border-bottom: 1px solid silver; }
.cm-s-default span.cm-semi { color: blue; font-weight: bold; }
.cm-s-default span.cm-dollar { color: orange; font-weight: bold; }
.cm-s-default span.cm-arrow { color: red; }
.cm-s-default span.cm-arrow { color: brown; }
.cm-s-default span.cm-arg-is { color: brown; }
</style>
<link rel="stylesheet" href="../../css/docs.css">
</head>
......
......@@ -46,6 +46,8 @@ CodeMirror.defineMode("r", function(config) {
return "variable-2";
} else if (ch == "<" && stream.eat("-")) {
return "arrow";
} else if (ch == "=" && state.ctx.argList) {
return "arg-is";
} else if (opChars.test(ch)) {
if (ch == "$") return "dollar";
stream.eatWhile(opChars);
......@@ -98,7 +100,8 @@ CodeMirror.defineMode("r", function(config) {
ctx: {type: "top",
indent: -config.indentUnit,
align: false},
indent: 0};
indent: 0,
afterIdent: false};
},
token: function(stream, state) {
......@@ -113,10 +116,14 @@ CodeMirror.defineMode("r", function(config) {
var ctype = state.ctx.type;
if ((curPunc == ";" || curPunc == "{" || curPunc == "}") && ctype == "block") pop(state);
if (curPunc == "{") push(state, "}", stream);
else if (curPunc == "(") push(state, ")", stream);
else if (curPunc == "(") {
push(state, ")", stream);
if (state.afterIdent) state.ctx.argList = true;
}
else if (curPunc == "[") push(state, "]", stream);
else if (curPunc == "block") push(state, "block", stream);
else if (curPunc == ctype) pop(state);
state.afterIdent = style == "variable" || style == "keyword";
return style;
},
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment