codemirror-rails 3.14 → 3.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/lib/codemirror/rails/version.rb +2 -2
  3. data/vendor/assets/javascripts/codemirror.js +178 -94
  4. data/vendor/assets/javascripts/codemirror/addons/comment/comment.js +3 -3
  5. data/vendor/assets/javascripts/codemirror/addons/edit/closebrackets.js +3 -1
  6. data/vendor/assets/javascripts/codemirror/addons/edit/matchtags.js +51 -0
  7. data/vendor/assets/javascripts/codemirror/addons/fold/brace-fold.js +9 -6
  8. data/vendor/assets/javascripts/codemirror/addons/fold/foldcode.js +9 -4
  9. data/vendor/assets/javascripts/codemirror/addons/fold/foldgutter.js +122 -0
  10. data/vendor/assets/javascripts/codemirror/addons/fold/indent-fold.js +3 -2
  11. data/vendor/assets/javascripts/codemirror/addons/fold/xml-fold.js +24 -17
  12. data/vendor/assets/javascripts/codemirror/addons/hint/anyword-hint.js +34 -0
  13. data/vendor/assets/javascripts/codemirror/addons/hint/html-hint.js +5 -3
  14. data/vendor/assets/javascripts/codemirror/addons/hint/javascript-hint.js +7 -3
  15. data/vendor/assets/javascripts/codemirror/addons/hint/pig-hint.js +4 -2
  16. data/vendor/assets/javascripts/codemirror/addons/hint/python-hint.js +4 -2
  17. data/vendor/assets/javascripts/codemirror/addons/hint/show-hint.js +6 -2
  18. data/vendor/assets/javascripts/codemirror/addons/hint/xml-hint.js +5 -2
  19. data/vendor/assets/javascripts/codemirror/addons/lint/coffeescript-lint.js +3 -2
  20. data/vendor/assets/javascripts/codemirror/addons/lint/javascript-lint.js +3 -6
  21. data/vendor/assets/javascripts/codemirror/addons/lint/json-lint.js +3 -2
  22. data/vendor/assets/javascripts/codemirror/addons/lint/lint.js +12 -6
  23. data/vendor/assets/javascripts/codemirror/addons/merge/dep/diff_match_patch.js +50 -0
  24. data/vendor/assets/javascripts/codemirror/addons/merge/merge.js +40 -24
  25. data/vendor/assets/javascripts/codemirror/addons/runmode/runmode-standalone.js +3 -1
  26. data/vendor/assets/javascripts/codemirror/addons/runmode/runmode.node.js +3 -1
  27. data/vendor/assets/javascripts/codemirror/addons/search/match-highlighter.js +11 -9
  28. data/vendor/assets/javascripts/codemirror/addons/selection/active-line.js +1 -1
  29. data/vendor/assets/javascripts/codemirror/addons/tern/tern.js +608 -0
  30. data/vendor/assets/javascripts/codemirror/addons/tern/worker.js +39 -0
  31. data/vendor/assets/javascripts/codemirror/keymaps/vim.js +120 -101
  32. data/vendor/assets/javascripts/codemirror/modes/clike.js +2 -1
  33. data/vendor/assets/javascripts/codemirror/modes/coffeescript.js +2 -1
  34. data/vendor/assets/javascripts/codemirror/modes/css.js +33 -16
  35. data/vendor/assets/javascripts/codemirror/modes/groovy.js +2 -1
  36. data/vendor/assets/javascripts/codemirror/modes/jade.js +90 -0
  37. data/vendor/assets/javascripts/codemirror/modes/javascript.js +21 -18
  38. data/vendor/assets/javascripts/codemirror/modes/markdown.js +26 -1
  39. data/vendor/assets/javascripts/codemirror/modes/nginx.js +163 -0
  40. data/vendor/assets/javascripts/codemirror/modes/python.js +19 -2
  41. data/vendor/assets/javascripts/codemirror/modes/rst.js +30 -19
  42. data/vendor/assets/javascripts/codemirror/modes/ruby.js +4 -4
  43. data/vendor/assets/javascripts/codemirror/modes/rust.js +2 -1
  44. data/vendor/assets/javascripts/codemirror/modes/scss_test.js +1 -1
  45. data/vendor/assets/javascripts/codemirror/modes/smalltalk.js +12 -2
  46. data/vendor/assets/javascripts/codemirror/modes/smartymixed.js +170 -0
  47. data/vendor/assets/javascripts/codemirror/modes/sparql.js +4 -2
  48. data/vendor/assets/javascripts/codemirror/modes/vbscript.js +330 -22
  49. data/vendor/assets/javascripts/codemirror/modes/xml.js +18 -3
  50. data/vendor/assets/stylesheets/codemirror.css +10 -0
  51. data/vendor/assets/stylesheets/codemirror/addons/merge/merge.css +39 -29
  52. data/vendor/assets/stylesheets/codemirror/addons/tern/tern.css +85 -0
  53. data/vendor/assets/stylesheets/codemirror/themes/3024-day.css +33 -0
  54. data/vendor/assets/stylesheets/codemirror/themes/3024-night.css +33 -0
  55. data/vendor/assets/stylesheets/codemirror/themes/base16-dark.css +33 -0
  56. data/vendor/assets/stylesheets/codemirror/themes/base16-light.css +33 -0
  57. data/vendor/assets/stylesheets/codemirror/themes/lesser-dark.css +1 -1
  58. data/vendor/assets/stylesheets/codemirror/themes/midnight.css +5 -14
  59. data/vendor/assets/stylesheets/codemirror/themes/tomorrow-night-eighties.css +33 -0
  60. data/vendor/assets/stylesheets/codemirror/themes/vibrant-ink.css +2 -2
  61. metadata +17 -2
@@ -158,7 +158,8 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
158
158
  electricChars: "{}",
159
159
  blockCommentStart: "/*",
160
160
  blockCommentEnd: "*/",
161
- lineComment: "//"
161
+ lineComment: "//",
162
+ fold: "brace"
162
163
  };
163
164
  });
164
165
 
@@ -339,7 +339,8 @@ CodeMirror.defineMode('coffeescript', function(conf) {
339
339
  return state.scopes[0].offset;
340
340
  },
341
341
 
342
- lineComment: "#"
342
+ lineComment: "#",
343
+ fold: "indent"
343
344
  };
344
345
  return external;
345
346
  });
@@ -103,7 +103,8 @@ CodeMirror.defineMode("css-base", function(config, parserConfig) {
103
103
  startState: function(base) {
104
104
  return {tokenize: tokenBase,
105
105
  baseIndent: base || 0,
106
- stack: []};
106
+ stack: [],
107
+ lastToken: null};
107
108
  },
108
109
 
109
110
  token: function(stream, state) {
@@ -163,7 +164,7 @@ CodeMirror.defineMode("css-base", function(config, parserConfig) {
163
164
  var context = state.stack[state.stack.length-1];
164
165
  if (style == "variable") {
165
166
  if (type == "variable-definition") state.stack.push("propertyValue");
166
- return "variable-2";
167
+ return state.lastToken = "variable-2";
167
168
  } else if (style == "property") {
168
169
  var word = stream.current().toLowerCase();
169
170
  if (context == "propertyValue") {
@@ -251,7 +252,6 @@ CodeMirror.defineMode("css-base", function(config, parserConfig) {
251
252
  // Push/pop context stack
252
253
  if (type == "{") {
253
254
  if (context == "@media" || context == "@mediaType") {
254
- state.stack.pop();
255
255
  state.stack[state.stack.length-1] = "@media{";
256
256
  }
257
257
  else {
@@ -260,8 +260,7 @@ CodeMirror.defineMode("css-base", function(config, parserConfig) {
260
260
  }
261
261
  }
262
262
  else if (type == "}") {
263
- var lastState = state.stack[state.stack.length - 1];
264
- if (lastState == "interpolation") style = "operator";
263
+ if (context == "interpolation") style = "operator";
265
264
  state.stack.pop();
266
265
  if (context == "propertyValue") state.stack.pop();
267
266
  }
@@ -269,26 +268,44 @@ CodeMirror.defineMode("css-base", function(config, parserConfig) {
269
268
  else if (type == "@media") state.stack.push("@media");
270
269
  else if (type == "@import") state.stack.push("@import");
271
270
  else if (context == "@media" && /\b(keyword|attribute)\b/.test(style))
272
- state.stack.push("@mediaType");
273
- else if (context == "@mediaType" && stream.current() == ",") state.stack.pop();
274
- else if (context == "@mediaType" && type == "(") state.stack.push("@mediaType(");
275
- else if (context == "@mediaType(" && type == ")") state.stack.pop();
276
- else if ((context == "rule" || context == "block") && type == ":") state.stack.push("propertyValue");
271
+ state.stack[state.stack.length-1] = "@mediaType";
272
+ else if (context == "@mediaType" && stream.current() == ",")
273
+ state.stack[state.stack.length-1] = "@media";
274
+ else if (type == "(") {
275
+ if (context == "@media" || context == "@mediaType") {
276
+ // Make sure @mediaType is used to avoid error on {
277
+ state.stack[state.stack.length-1] = "@mediaType";
278
+ state.stack.push("@mediaType(");
279
+ }
280
+ }
281
+ else if (type == ")") {
282
+ if (context == "propertyValue" && state.stack[state.stack.length-2] == "@mediaType(") {
283
+ // In @mediaType( without closing ; after propertyValue
284
+ state.stack.pop();
285
+ state.stack.pop();
286
+ }
287
+ else if (context == "@mediaType(") {
288
+ state.stack.pop();
289
+ }
290
+ }
291
+ else if (type == ":" && state.lastToken == "property") state.stack.push("propertyValue");
277
292
  else if (context == "propertyValue" && type == ";") state.stack.pop();
278
293
  else if (context == "@import" && type == ";") state.stack.pop();
279
- return style;
294
+
295
+ return state.lastToken = style;
280
296
  },
281
297
 
282
298
  indent: function(state, textAfter) {
283
299
  var n = state.stack.length;
284
300
  if (/^\}/.test(textAfter))
285
- n -= state.stack[state.stack.length-1] == "propertyValue" ? 2 : 1;
301
+ n -= state.stack[n-1] == "propertyValue" ? 2 : 1;
286
302
  return state.baseIndent + n * indentUnit;
287
303
  },
288
304
 
289
305
  electricChars: "}",
290
306
  blockCommentStart: "/*",
291
- blockCommentEnd: "*/"
307
+ blockCommentEnd: "*/",
308
+ fold: "brace"
292
309
  };
293
310
  });
294
311
 
@@ -384,15 +401,15 @@ CodeMirror.defineMode("css-base", function(config, parserConfig) {
384
401
  "text-decoration-color", "text-decoration-line", "text-decoration-skip",
385
402
  "text-decoration-style", "text-emphasis", "text-emphasis-color",
386
403
  "text-emphasis-position", "text-emphasis-style", "text-height",
387
- "text-indent", "text-justify", "text-outline", "text-shadow",
388
- "text-space-collapse", "text-transform", "text-underline-position",
404
+ "text-indent", "text-justify", "text-outline", "text-overflow", "text-shadow",
405
+ "text-size-adjust", "text-space-collapse", "text-transform", "text-underline-position",
389
406
  "text-wrap", "top", "transform", "transform-origin", "transform-style",
390
407
  "transition", "transition-delay", "transition-duration",
391
408
  "transition-property", "transition-timing-function", "unicode-bidi",
392
409
  "vertical-align", "visibility", "voice-balance", "voice-duration",
393
410
  "voice-family", "voice-pitch", "voice-range", "voice-rate", "voice-stress",
394
411
  "voice-volume", "volume", "white-space", "widows", "width", "word-break",
395
- "word-spacing", "word-wrap", "z-index",
412
+ "word-spacing", "word-wrap", "z-index", "zoom",
396
413
  // SVG-specific
397
414
  "clip-path", "clip-rule", "mask", "enable-background", "filter", "flood-color",
398
415
  "flood-opacity", "lighting-color", "stop-color", "stop-opacity", "pointer-events",
@@ -203,7 +203,8 @@ CodeMirror.defineMode("groovy", function(config) {
203
203
  else return ctx.indented + (closing ? 0 : config.indentUnit);
204
204
  },
205
205
 
206
- electricChars: "{}"
206
+ electricChars: "{}",
207
+ fold: "brace"
207
208
  };
208
209
  });
209
210
 
@@ -0,0 +1,90 @@
1
+ CodeMirror.defineMode("jade", function () {
2
+ var symbol_regex1 = /^(?:~|!|%|\^|\*|\+|=|\\|:|;|,|\/|\?|&|<|>|\|)/;
3
+ var open_paren_regex = /^(\(|\[)/;
4
+ var close_paren_regex = /^(\)|\])/;
5
+ var keyword_regex1 = /^(if|else|return|var|function|include|doctype|each)/;
6
+ var keyword_regex2 = /^(#|{|}|\.)/;
7
+ var keyword_regex3 = /^(in)/;
8
+ var html_regex1 = /^(html|head|title|meta|link|script|body|br|div|input|span|a|img)/;
9
+ var html_regex2 = /^(h1|h2|h3|h4|h5|p|strong|em)/;
10
+ return {
11
+ startState: function () {
12
+ return {
13
+ inString: false,
14
+ stringType: "",
15
+ beforeTag: true,
16
+ justMatchedKeyword: false,
17
+ afterParen: false
18
+ };
19
+ },
20
+ token: function (stream, state) {
21
+ //check for state changes
22
+ if (!state.inString && ((stream.peek() == '"') || (stream.peek() == "'"))) {
23
+ state.stringType = stream.peek();
24
+ stream.next(); // Skip quote
25
+ state.inString = true; // Update state
26
+ }
27
+
28
+ //return state
29
+ if (state.inString) {
30
+ if (stream.skipTo(state.stringType)) { // Quote found on this line
31
+ stream.next(); // Skip quote
32
+ state.inString = false; // Clear flag
33
+ } else {
34
+ stream.skipToEnd(); // Rest of line is string
35
+ }
36
+ state.justMatchedKeyword = false;
37
+ return "string"; // Token style
38
+ } else if (stream.sol() && stream.eatSpace()) {
39
+ if (stream.match(keyword_regex1)) {
40
+ state.justMatchedKeyword = true;
41
+ stream.eatSpace();
42
+ return "keyword";
43
+ }
44
+ if (stream.match(html_regex1) || stream.match(html_regex2)) {
45
+ state.justMatchedKeyword = true;
46
+ return "variable";
47
+ }
48
+ } else if (stream.sol() && stream.match(keyword_regex1)) {
49
+ state.justMatchedKeyword = true;
50
+ stream.eatSpace();
51
+ return "keyword";
52
+ } else if (stream.sol() && (stream.match(html_regex1) || stream.match(html_regex2))) {
53
+ state.justMatchedKeyword = true;
54
+ return "variable";
55
+ } else if (stream.eatSpace()) {
56
+ state.justMatchedKeyword = false;
57
+ if (stream.match(keyword_regex3) && stream.eatSpace()) {
58
+ state.justMatchedKeyword = true;
59
+ return "keyword";
60
+ }
61
+ } else if (stream.match(symbol_regex1)) {
62
+ state.justMatchedKeyword = false;
63
+ return "atom";
64
+ } else if (stream.match(open_paren_regex)) {
65
+ state.afterParen = true;
66
+ state.justMatchedKeyword = true;
67
+ return "def";
68
+ } else if (stream.match(close_paren_regex)) {
69
+ state.afterParen = false;
70
+ state.justMatchedKeyword = true;
71
+ return "def";
72
+ } else if (stream.match(keyword_regex2)) {
73
+ state.justMatchedKeyword = true;
74
+ return "keyword";
75
+ } else if (stream.eatSpace()) {
76
+ state.justMatchedKeyword = false;
77
+ } else {
78
+ stream.next();
79
+ if (state.justMatchedKeyword) {
80
+ return "property";
81
+ } else if (state.afterParen) {
82
+ return "property";
83
+ }
84
+ }
85
+ return null;
86
+ }
87
+ };
88
+ });
89
+
90
+ CodeMirror.defineMIME('text/x-jade', 'jade');
@@ -258,17 +258,17 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
258
258
  if (type == "keyword b") return cont(pushlex("form"), statement, poplex);
259
259
  if (type == "{") return cont(pushlex("}"), block, poplex);
260
260
  if (type == ";") return cont();
261
- if (type == "if") return cont(pushlex("form"), expression, statement, poplex, maybeelse(cx.state.indented));
261
+ if (type == "if") return cont(pushlex("form"), expression, statement, poplex, maybeelse);
262
262
  if (type == "function") return cont(functiondef);
263
263
  if (type == "for") return cont(pushlex("form"), expect("("), pushlex(")"), forspec1, expect(")"),
264
- poplex, statement, poplex);
264
+ poplex, statement, poplex);
265
265
  if (type == "variable") return cont(pushlex("stat"), maybelabel);
266
266
  if (type == "switch") return cont(pushlex("form"), expression, pushlex("}", "switch"), expect("{"),
267
- block, poplex, poplex);
267
+ block, poplex, poplex);
268
268
  if (type == "case") return cont(expression, expect(":"));
269
269
  if (type == "default") return cont(expect(":"));
270
270
  if (type == "catch") return cont(pushlex("form"), pushcontext, expect("("), funarg, expect(")"),
271
- statement, poplex, popcontext);
271
+ statement, poplex, popcontext);
272
272
  return pass(pushlex("stat"), expression, expect(";"), poplex);
273
273
  }
274
274
  function expression(type) {
@@ -299,19 +299,20 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
299
299
 
300
300
  function maybeoperatorComma(type, value) {
301
301
  if (type == ",") return cont(expression);
302
- return maybeoperatorNoComma(type, value, maybeoperatorComma);
302
+ return maybeoperatorNoComma(type, value, false);
303
303
  }
304
- function maybeoperatorNoComma(type, value, me) {
305
- if (!me) me = maybeoperatorNoComma;
304
+ function maybeoperatorNoComma(type, value, noComma) {
305
+ var me = noComma == false ? maybeoperatorComma : maybeoperatorNoComma;
306
+ var expr = noComma == false ? expression : expressionNoComma;
306
307
  if (type == "operator") {
307
308
  if (/\+\+|--/.test(value)) return cont(me);
308
- if (value == "?") return cont(expression, expect(":"), expression);
309
- return cont(expression);
309
+ if (value == "?") return cont(expression, expect(":"), expr);
310
+ return cont(expr);
310
311
  }
311
312
  if (type == ";") return;
312
313
  if (type == "(") return cont(pushlex(")", "call"), commasep(expressionNoComma, ")"), poplex, me);
313
314
  if (type == ".") return cont(property, me);
314
- if (type == "[") return cont(pushlex("]"), expression, expect("]"), poplex, me);
315
+ if (type == "[") return cont(pushlex("]"), maybeexpression, expect("]"), poplex, me);
315
316
  }
316
317
  function maybelabel(type) {
317
318
  if (type == ":") return cont(poplex, statement);
@@ -373,14 +374,8 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
373
374
  if (value == "=") return cont(expressionNoComma, vardef2);
374
375
  if (type == ",") return cont(vardef1);
375
376
  }
376
- function maybeelse(indent) {
377
- return function(type, value) {
378
- if (type == "keyword b" && value == "else") {
379
- cx.state.lexical = new JSLexical(indent, 0, "form", null, cx.state.lexical);
380
- return cont(statement, poplex);
381
- }
382
- return pass();
383
- };
377
+ function maybeelse(type, value) {
378
+ if (type == "keyword b" && value == "else") return cont(pushlex("form"), statement, poplex);
384
379
  }
385
380
  function forspec1(type) {
386
381
  if (type == "var") return cont(vardef1, expect(";"), forspec2);
@@ -441,6 +436,12 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
441
436
  if (state.tokenize == jsTokenComment) return CodeMirror.Pass;
442
437
  if (state.tokenize != jsTokenBase) return 0;
443
438
  var firstChar = textAfter && textAfter.charAt(0), lexical = state.lexical;
439
+ // Kludge to prevent 'maybelse' from blocking lexical scope pops
440
+ for (var i = state.cc.length - 1; i >= 0; --i) {
441
+ var c = state.cc[i];
442
+ if (c == poplex) lexical = lexical.prev;
443
+ else if (c != maybeelse || /^else\b/.test(textAfter)) break;
444
+ }
444
445
  if (lexical.type == "stat" && firstChar == "}") lexical = lexical.prev;
445
446
  if (statementIndent && lexical.type == ")" && lexical.prev.type == "stat")
446
447
  lexical = lexical.prev;
@@ -461,7 +462,9 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
461
462
  blockCommentStart: jsonMode ? null : "/*",
462
463
  blockCommentEnd: jsonMode ? null : "*/",
463
464
  lineComment: jsonMode ? null : "//",
465
+ fold: "brace",
464
466
 
467
+ helperType: jsonMode ? "json" : "javascript",
465
468
  jsonMode: jsonMode
466
469
  };
467
470
  });
@@ -103,6 +103,9 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
103
103
  state.f = inlineNormal;
104
104
  state.block = blockNormal;
105
105
  }
106
+ // Reset state.trailingSpace
107
+ state.trailingSpace = 0;
108
+ state.trailingSpaceNewLine = false;
106
109
  // Mark this line as blank
107
110
  state.thisLineHasContent = false;
108
111
  return null;
@@ -217,6 +220,12 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
217
220
  }
218
221
  }
219
222
 
223
+ if (state.trailingSpaceNewLine) {
224
+ styles.push("trailing-space-new-line");
225
+ } else if (state.trailingSpace) {
226
+ styles.push("trailing-space-" + (state.trailingSpace % 2 ? "a" : "b"));
227
+ }
228
+
220
229
  return styles.length ? styles.join(' ') : null;
221
230
  }
222
231
 
@@ -369,6 +378,14 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
369
378
  }
370
379
  }
371
380
 
381
+ if (ch === ' ') {
382
+ if (stream.match(/ +$/, false)) {
383
+ state.trailingSpace++;
384
+ } else if (state.trailingSpace) {
385
+ state.trailingSpaceNewLine = true;
386
+ }
387
+ }
388
+
372
389
  return getType(state);
373
390
  }
374
391
 
@@ -453,7 +470,9 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
453
470
  taskList: false,
454
471
  list: false,
455
472
  listDepth: 0,
456
- quote: 0
473
+ quote: 0,
474
+ trailingSpace: 0,
475
+ trailingSpaceNewLine: false
457
476
  };
458
477
  },
459
478
 
@@ -481,6 +500,8 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
481
500
  list: s.list,
482
501
  listDepth: s.listDepth,
483
502
  quote: s.quote,
503
+ trailingSpace: s.trailingSpace,
504
+ trailingSpaceNewLine: s.trailingSpaceNewLine,
484
505
  md_inside: s.md_inside
485
506
  };
486
507
  },
@@ -504,6 +525,10 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
504
525
  // Reset state.code
505
526
  state.code = false;
506
527
 
528
+ // Reset state.trailingSpace
529
+ state.trailingSpace = 0;
530
+ state.trailingSpaceNewLine = false;
531
+
507
532
  state.f = state.block;
508
533
  var indentation = stream.match(/^\s*/, true)[0].replace(/\t/g, ' ').length;
509
534
  var difference = Math.floor((indentation - state.indentation) / 4) * 4;
@@ -0,0 +1,163 @@
1
+ CodeMirror.defineMode("nginx", function(config) {
2
+
3
+ function words(str) {
4
+ var obj = {}, words = str.split(" ");
5
+ for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
6
+ return obj;
7
+ }
8
+
9
+ var keywords = words(
10
+ /* ngxDirectiveControl */ "break return rewrite set" +
11
+ /* ngxDirective */ " accept_mutex accept_mutex_delay access_log add_after_body add_before_body add_header addition_types aio alias allow ancient_browser ancient_browser_value auth_basic auth_basic_user_file auth_http auth_http_header auth_http_timeout autoindex autoindex_exact_size autoindex_localtime charset charset_types client_body_buffer_size client_body_in_file_only client_body_in_single_buffer client_body_temp_path client_body_timeout client_header_buffer_size client_header_timeout client_max_body_size connection_pool_size create_full_put_path daemon dav_access dav_methods debug_connection debug_points default_type degradation degrade deny devpoll_changes devpoll_events directio directio_alignment empty_gif env epoll_events error_log eventport_events expires fastcgi_bind fastcgi_buffer_size fastcgi_buffers fastcgi_busy_buffers_size fastcgi_cache fastcgi_cache_key fastcgi_cache_methods fastcgi_cache_min_uses fastcgi_cache_path fastcgi_cache_use_stale fastcgi_cache_valid fastcgi_catch_stderr fastcgi_connect_timeout fastcgi_hide_header fastcgi_ignore_client_abort fastcgi_ignore_headers fastcgi_index fastcgi_intercept_errors fastcgi_max_temp_file_size fastcgi_next_upstream fastcgi_param fastcgi_pass_header fastcgi_pass_request_body fastcgi_pass_request_headers fastcgi_read_timeout fastcgi_send_lowat fastcgi_send_timeout fastcgi_split_path_info fastcgi_store fastcgi_store_access fastcgi_temp_file_write_size fastcgi_temp_path fastcgi_upstream_fail_timeout fastcgi_upstream_max_fails flv geoip_city geoip_country google_perftools_profiles gzip gzip_buffers gzip_comp_level gzip_disable gzip_hash gzip_http_version gzip_min_length gzip_no_buffer gzip_proxied gzip_static gzip_types gzip_vary gzip_window if_modified_since ignore_invalid_headers image_filter image_filter_buffer image_filter_jpeg_quality image_filter_transparency imap_auth imap_capabilities imap_client_buffer index ip_hash keepalive_requests keepalive_timeout kqueue_changes kqueue_events large_client_header_buffers limit_conn limit_conn_log_level limit_rate limit_rate_after limit_req limit_req_log_level limit_req_zone limit_zone lingering_time lingering_timeout lock_file log_format log_not_found log_subrequest map_hash_bucket_size map_hash_max_size master_process memcached_bind memcached_buffer_size memcached_connect_timeout memcached_next_upstream memcached_read_timeout memcached_send_timeout memcached_upstream_fail_timeout memcached_upstream_max_fails merge_slashes min_delete_depth modern_browser modern_browser_value msie_padding msie_refresh multi_accept open_file_cache open_file_cache_errors open_file_cache_events open_file_cache_min_uses open_file_cache_valid open_log_file_cache output_buffers override_charset perl perl_modules perl_require perl_set pid pop3_auth pop3_capabilities port_in_redirect postpone_gzipping postpone_output protocol proxy proxy_bind proxy_buffer proxy_buffer_size proxy_buffering proxy_buffers proxy_busy_buffers_size proxy_cache proxy_cache_key proxy_cache_methods proxy_cache_min_uses proxy_cache_path proxy_cache_use_stale proxy_cache_valid proxy_connect_timeout proxy_headers_hash_bucket_size proxy_headers_hash_max_size proxy_hide_header proxy_ignore_client_abort proxy_ignore_headers proxy_intercept_errors proxy_max_temp_file_size proxy_method proxy_next_upstream proxy_pass_error_message proxy_pass_header proxy_pass_request_body proxy_pass_request_headers proxy_read_timeout proxy_redirect proxy_send_lowat proxy_send_timeout proxy_set_body proxy_set_header proxy_ssl_session_reuse proxy_store proxy_store_access proxy_temp_file_write_size proxy_temp_path proxy_timeout proxy_upstream_fail_timeout proxy_upstream_max_fails random_index read_ahead real_ip_header recursive_error_pages request_pool_size reset_timedout_connection resolver resolver_timeout rewrite_log rtsig_overflow_events rtsig_overflow_test rtsig_overflow_threshold rtsig_signo satisfy secure_link_secret send_lowat send_timeout sendfile sendfile_max_chunk server_name_in_redirect server_names_hash_bucket_size server_names_hash_max_size server_tokens set_real_ip_from smtp_auth smtp_capabilities smtp_client_buffer smtp_greeting_delay so_keepalive source_charset ssi ssi_ignore_recycled_buffers ssi_min_file_chunk ssi_silent_errors ssi_types ssi_value_length ssl ssl_certificate ssl_certificate_key ssl_ciphers ssl_client_certificate ssl_crl ssl_dhparam ssl_engine ssl_prefer_server_ciphers ssl_protocols ssl_session_cache ssl_session_timeout ssl_verify_client ssl_verify_depth starttls stub_status sub_filter sub_filter_once sub_filter_types tcp_nodelay tcp_nopush thread_stack_size timeout timer_resolution types_hash_bucket_size types_hash_max_size underscores_in_headers uninitialized_variable_warn use user userid userid_domain userid_expires userid_mark userid_name userid_p3p userid_path userid_service valid_referers variables_hash_bucket_size variables_hash_max_size worker_connections worker_cpu_affinity worker_priority worker_processes worker_rlimit_core worker_rlimit_nofile worker_rlimit_sigpending worker_threads working_directory xclient xml_entities xslt_stylesheet xslt_typesdrew@li229-23"
12
+ );
13
+
14
+ var keywords_block = words(
15
+ /* ngxDirectiveBlock */ "http mail events server types location upstream charset_map limit_except if geo map"
16
+ );
17
+
18
+ var keywords_important = words(
19
+ /* ngxDirectiveImportant */ "include root server server_name listen internal proxy_pass memcached_pass fastcgi_pass try_files"
20
+ );
21
+
22
+ var indentUnit = config.indentUnit, type;
23
+ function ret(style, tp) {type = tp; return style;}
24
+
25
+ function tokenBase(stream, state) {
26
+
27
+
28
+ stream.eatWhile(/[\w\$_]/);
29
+
30
+ var cur = stream.current();
31
+
32
+
33
+ if (keywords.propertyIsEnumerable(cur)) {
34
+ return "keyword";
35
+ }
36
+ else if (keywords_block.propertyIsEnumerable(cur)) {
37
+ return "variable-2";
38
+ }
39
+ else if (keywords_important.propertyIsEnumerable(cur)) {
40
+ return "string-2";
41
+ }
42
+ /**/
43
+
44
+ var ch = stream.next();
45
+ if (ch == "@") {stream.eatWhile(/[\w\\\-]/); return ret("meta", stream.current());}
46
+ else if (ch == "/" && stream.eat("*")) {
47
+ state.tokenize = tokenCComment;
48
+ return tokenCComment(stream, state);
49
+ }
50
+ else if (ch == "<" && stream.eat("!")) {
51
+ state.tokenize = tokenSGMLComment;
52
+ return tokenSGMLComment(stream, state);
53
+ }
54
+ else if (ch == "=") ret(null, "compare");
55
+ else if ((ch == "~" || ch == "|") && stream.eat("=")) return ret(null, "compare");
56
+ else if (ch == "\"" || ch == "'") {
57
+ state.tokenize = tokenString(ch);
58
+ return state.tokenize(stream, state);
59
+ }
60
+ else if (ch == "#") {
61
+ stream.skipToEnd();
62
+ return ret("comment", "comment");
63
+ }
64
+ else if (ch == "!") {
65
+ stream.match(/^\s*\w*/);
66
+ return ret("keyword", "important");
67
+ }
68
+ else if (/\d/.test(ch)) {
69
+ stream.eatWhile(/[\w.%]/);
70
+ return ret("number", "unit");
71
+ }
72
+ else if (/[,.+>*\/]/.test(ch)) {
73
+ return ret(null, "select-op");
74
+ }
75
+ else if (/[;{}:\[\]]/.test(ch)) {
76
+ return ret(null, ch);
77
+ }
78
+ else {
79
+ stream.eatWhile(/[\w\\\-]/);
80
+ return ret("variable", "variable");
81
+ }
82
+ }
83
+
84
+ function tokenCComment(stream, state) {
85
+ var maybeEnd = false, ch;
86
+ while ((ch = stream.next()) != null) {
87
+ if (maybeEnd && ch == "/") {
88
+ state.tokenize = tokenBase;
89
+ break;
90
+ }
91
+ maybeEnd = (ch == "*");
92
+ }
93
+ return ret("comment", "comment");
94
+ }
95
+
96
+ function tokenSGMLComment(stream, state) {
97
+ var dashes = 0, ch;
98
+ while ((ch = stream.next()) != null) {
99
+ if (dashes >= 2 && ch == ">") {
100
+ state.tokenize = tokenBase;
101
+ break;
102
+ }
103
+ dashes = (ch == "-") ? dashes + 1 : 0;
104
+ }
105
+ return ret("comment", "comment");
106
+ }
107
+
108
+ function tokenString(quote) {
109
+ return function(stream, state) {
110
+ var escaped = false, ch;
111
+ while ((ch = stream.next()) != null) {
112
+ if (ch == quote && !escaped)
113
+ break;
114
+ escaped = !escaped && ch == "\\";
115
+ }
116
+ if (!escaped) state.tokenize = tokenBase;
117
+ return ret("string", "string");
118
+ };
119
+ }
120
+
121
+ return {
122
+ startState: function(base) {
123
+ return {tokenize: tokenBase,
124
+ baseIndent: base || 0,
125
+ stack: []};
126
+ },
127
+
128
+ token: function(stream, state) {
129
+ if (stream.eatSpace()) return null;
130
+ type = null;
131
+ var style = state.tokenize(stream, state);
132
+
133
+ var context = state.stack[state.stack.length-1];
134
+ if (type == "hash" && context == "rule") style = "atom";
135
+ else if (style == "variable") {
136
+ if (context == "rule") style = "number";
137
+ else if (!context || context == "@media{") style = "tag";
138
+ }
139
+
140
+ if (context == "rule" && /^[\{\};]$/.test(type))
141
+ state.stack.pop();
142
+ if (type == "{") {
143
+ if (context == "@media") state.stack[state.stack.length-1] = "@media{";
144
+ else state.stack.push("{");
145
+ }
146
+ else if (type == "}") state.stack.pop();
147
+ else if (type == "@media") state.stack.push("@media");
148
+ else if (context == "{" && type != "comment") state.stack.push("rule");
149
+ return style;
150
+ },
151
+
152
+ indent: function(state, textAfter) {
153
+ var n = state.stack.length;
154
+ if (/^\}/.test(textAfter))
155
+ n -= state.stack[state.stack.length-1] == "rule" ? 2 : 1;
156
+ return state.baseIndent + n * indentUnit;
157
+ },
158
+
159
+ electricChars: "}"
160
+ };
161
+ });
162
+
163
+ CodeMirror.defineMIME("text/nginx", "text/x-nginx-conf");