diff --git a/mode/rust/index.html b/mode/rust/index.html index c8eac943ce10ca0e3fc28058cddc356069571e63..1fe0ad1e66e254c427850454637954f497dcd88f 100644 --- a/mode/rust/index.html +++ b/mode/rust/index.html @@ -38,15 +38,15 @@ enum bar { fn check_crate(x: int) { let v = 10; - alt foo { - 1 to 3 { - print_foo(); - if x { - blah() + 10; + match foo { + 1 ... 3 { + print_foo(); + if x { + blah().to_string(); + } } - } - (x, y) { "bye" } - _ { "hi" } + (x, y) { "bye" } + _ { "hi" } } } </textarea></div> @@ -56,8 +56,6 @@ fn check_crate(x: int) { lineNumbers: true, lineWrapping: true, indentUnit: 4, - tabSize: 2, - autofocus: true, mode: "rust" }); </script> diff --git a/mode/rust/rust.js b/mode/rust/rust.js index df8d2447180a0a1282795cba547a845a75b182a6..1ce0c01ee52cc5635a3acee0a5564b37df7d678f 100644 --- a/mode/rust/rust.js +++ b/mode/rust/rust.js @@ -3,9 +3,9 @@ (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS - mod(require("../../lib/codemirror")); + mod(require("../../lib/codemirror"), require("../../addon/mode/simple")); else if (typeof define == "function" && define.amd) // AMD - define(["../../lib/codemirror"], mod); + define(["../../lib/codemirror", "../../addon/mode/simple"], mod); else // Plain browser env mod(CodeMirror); })(function(CodeMirror) { @@ -16,7 +16,7 @@ CodeMirror.defineSimpleMode("rust",{ // string and byte string {regex: /b?"(?:[^\\]|\\.)*?"/, token: "string"}, // raw string and raw byte string - {regex: /(b?r)(#*)(".*)("\2)/, token: ["string", "string", "string", "string"]}, + {regex: /(b?r)(#*)(".*?)("\2)/, token: ["string", "string", "string", "string"]}, // character {regex: /'(?:[^'\\]|\\(?:[nrt0'"]|x[\da-fA-F]{2}|u\{[\da-fA-F]{6}\}))'/, token: "string-2"}, // byte @@ -24,20 +24,20 @@ CodeMirror.defineSimpleMode("rust",{ {regex: /(?:(?:[0-9][0-9_]*)(?:(?:[Ee][+-]?[0-9_]+)|\.[0-9_]+(?:[Ee][+-]?[0-9_]+)?)(?:f32|f64)?)|(?:0(?:b[01_]+|(?:o[0-7_]+)|(?:x[0-9a-fA-F_]+))|(?:[0-9][0-9_]*))(?:u8|u16|u32|u64|i8|i16|i32|i64|isize|usize)?/, token: "number"}, - {regex: /(let\s+(?:mut\s+)?)([a-zA-Z_][a-zA-Z0-9_]*)/, token: ["keyword", "def"]}, - {regex: /(?:abstract|alignof|as|box|break|continue|const|crate|do|else|enum|extern|for|final|if|impl|in|loop|macro|match|mod|move|offsetof|override|priv|proc|pub|pure|ref|return|self|sizeof|static|struct|super|trait|type|typeof|unsafe|unsized|use|virtual|where|while|yield)\b/, token: "keyword"}, + {regex: /(let(?:\s+mut)?|fn|enum|mod|struct|type)(\s+)([a-zA-Z_][a-zA-Z0-9_]*)/, token: ["keyword", null, "def"]}, + {regex: /(?:abstract|alignof|as|box|break|continue|const|crate|do|else|enum|extern|fn|for|final|if|impl|in|loop|macro|match|mod|move|offsetof|override|priv|proc|pub|pure|ref|return|self|sizeof|static|struct|super|trait|type|typeof|unsafe|unsized|use|virtual|where|while|yield)\b/, token: "keyword"}, {regex: /\b(?:Self|isize|usize|char|bool|u8|u16|u32|u64|f16|f32|f64|i8|i16|i32|i64|str|Option)\b/, token: "atom"}, {regex: /\b(?:true|false|Some|None|Ok|Err)\b/, token: "builtin"}, {regex: /\b(fn)(\s+)([a-zA-Z_][a-zA-Z0-9_]*)/, token: ["keyword", null ,"def"]}, - {regex: /#!?\[.*\]/, token: "attribute"}, + {regex: /#!?\[.*\]/, token: "meta"}, {regex: /\/\/.*/, token: "comment"}, {regex: /\/\*/, token: "comment", next: "comment"}, {regex: /[-+\/*=<>!]+/, token: "operator"}, {regex: /[a-zA-Z_]\w*!/,token: "variable-3"}, {regex: /[a-zA-Z_]\w*/, token: "variable"}, {regex: /[\{\[\(]/, indent: true}, - {regex: /[\}\]\)]/, dedent: true}, + {regex: /[\}\]\)]/, dedent: true} ], comment: [ {regex: /.*?\*\//, token: "comment", next: "start"}, @@ -45,7 +45,11 @@ CodeMirror.defineSimpleMode("rust",{ ], meta: { dontIndentStates: ["comment"], - lineComment: "//" + electricInput: /^\s*\}$/, + blockCommentStart: "/*", + blockCommentEnd: "*/", + lineComment: "//", + fold: "brace" } }); diff --git a/mode/rust/test.js b/mode/rust/test.js index 858c6be0f59480ea4ac5cb158624b1e2eece09bf..1a3c6e72073016d17def0848960bffdf56b71bb7 100644 --- a/mode/rust/test.js +++ b/mode/rust/test.js @@ -1,3 +1,5 @@ +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: http://codemirror.net/LICENSE (function() { var mode = CodeMirror.getMode({indentUnit: 4}, "rust");