├── .gitignore ├── Rust.xclangspec ├── Rust.xcspec └── install.sh /.gitignore: -------------------------------------------------------------------------------- 1 | .*.swp -------------------------------------------------------------------------------- /Rust.xclangspec: -------------------------------------------------------------------------------- 1 | /* 2 | Place this file in directory: 3 | ~/Library/Application Support/Developer/Shared/Xcode/Specifications/ 4 | */ 5 | 6 | ( 7 | // ---------------------------------------------------------------------------- 8 | // Keywords 9 | { 10 | Identifier = "xcode.lang.rust.identifier"; 11 | Syntax = { 12 | StartChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_"; 13 | Chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_"; 14 | Words = ( 15 | "as", 16 | "box", 17 | "break", 18 | "continue", 19 | "crate", 20 | "else", 21 | "enum", 22 | "extern", 23 | "false", 24 | "fn", 25 | "for", 26 | "if", 27 | "impl", 28 | "in", 29 | "let", 30 | "loop", 31 | "match", 32 | "mod", 33 | "mut", 34 | "priv", 35 | "proc", 36 | "pub", 37 | "ref", 38 | "return", 39 | "self", 40 | "static", 41 | "struct", 42 | "super", 43 | "true", 44 | "trait", 45 | "type", 46 | "unsafe", 47 | "use", 48 | "while", 49 | 50 | "alignof", 51 | "be", 52 | "do", 53 | "offsetof", 54 | "priv", 55 | "pure", 56 | "sizeof", 57 | "typeof", 58 | "unsized", 59 | "yield", 60 | 61 | "int", 62 | "uint", 63 | "float", 64 | "char", 65 | "bool", 66 | "u8", 67 | "u16", 68 | "u32", 69 | "u64", 70 | "f32", 71 | "f64", 72 | "i8", 73 | "i16", 74 | "i32", 75 | "i64", 76 | "str", 77 | "Self", 78 | 79 | "Copy", 80 | "Send", 81 | "Sized", 82 | "Share", 83 | "Add", 84 | "Sub", 85 | "Mul", 86 | "Div", 87 | "Rem", 88 | "Neg", 89 | "Not", 90 | "BitAnd", 91 | "BitOr", 92 | "BitXor", 93 | "Drop", 94 | "Deref", 95 | "DerefMut", 96 | "Shl", 97 | "Shr", 98 | "Index", 99 | "Option", 100 | "Some", 101 | "None", 102 | "Result", 103 | "Ok", 104 | "Err", 105 | 106 | "Ascii", 107 | "AsciiCast", 108 | "OwnedAsciiCast", 109 | "AsciiStr", 110 | "IntoBytes", 111 | "ToCStr", 112 | "Char", 113 | "Clone", 114 | "Eq", 115 | "Ord", 116 | "TotalEq", 117 | "TotalOrd", 118 | "Ordering", 119 | "Equiv", 120 | "Less", 121 | "Equal", 122 | "Greater", 123 | "Container", 124 | "Mutable", 125 | "Map", 126 | "MutableMap", 127 | "Set", 128 | "MutableSet", 129 | "FromIterator", 130 | "Extendable", 131 | "Iterator", 132 | "DoubleEndedIterator", 133 | "RandomAccessIterator", 134 | "CloneableIterator", 135 | "OrdIterator", 136 | "MutableDoubleEndedIterator", 137 | "ExactSize", 138 | "Num", 139 | "NumCast", 140 | "CheckedAdd", 141 | "CheckedSub", 142 | "CheckedMul", 143 | "Signed", 144 | "Unsigned", 145 | "Primitive", 146 | "Int", 147 | "Float", 148 | "FloatMath", 149 | "ToPrimitive", 150 | 151 | "Box", 152 | "GenericPath", 153 | "Path", 154 | "PosixPath", 155 | "WindowsPath", 156 | "RawPtr", 157 | "Buffer", 158 | "Writer", 159 | "Reader", 160 | "Seek", 161 | "Str", 162 | "StrVector", 163 | "StrSlice", 164 | "OwnedStr", 165 | "IntoMaybeOwned", 166 | "StrAllocating", 167 | "ToStr", 168 | "IntoStr", 169 | "Tuple1", 170 | "Tuple2", 171 | "Tuple3", 172 | "Tuple4", 173 | "Tuple5", 174 | "Tuple6", 175 | "Tuple7", 176 | "Tuple8", 177 | "Tuple9", 178 | "Tuple10", 179 | "Tuple11", 180 | "Tuple12", 181 | "CloneableVector", 182 | "ImmutableCloneableVector", 183 | "MutableCloneableVector", 184 | "ImmutableVector", 185 | "MutableVector", 186 | "ImmutableEqVector", 187 | "ImmutableTotalOrdVector", 188 | "MutableTotalOrdVector", 189 | "Vector", 190 | "VectorVector", 191 | "OwnedVector", 192 | "MutableVectorAllocating", 193 | "String", 194 | "Vec", 195 | 196 | "SyncSender", 197 | "Sender", 198 | "Receiver", 199 | ); 200 | Type = "xcode.syntax.keyword"; 201 | AltType = "xcode.syntax.identifier"; // non-keywords are identifiers 202 | }; 203 | }, 204 | 205 | { 206 | Identifier = "xcode.lang.rust.macro.identifier"; 207 | Syntax = { 208 | StartChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_"; 209 | Chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_"; 210 | Type = "xcode.syntax.preprocessor.identifier"; 211 | }; 212 | }, 213 | 214 | { 215 | Identifier = "xcode.lang.rust.macro.name"; 216 | Syntax = { 217 | StartChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_"; 218 | Chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_"; 219 | EndChars = "!"; 220 | Words = ( 221 | "macro_rules!", 222 | "assert!", 223 | "fail!", 224 | ); 225 | Type = "xcode.syntax.preprocessor.keyword"; 226 | AltType = "xcode.syntax.preprocessor.identifier"; // non-keywords are identifiers 227 | }; 228 | }, 229 | 230 | { 231 | Identifier = "xcode.lang.rust.interestingOperators"; 232 | Syntax = { 233 | Words = ( 234 | "..", 235 | ".", 236 | ":", 237 | "::", 238 | "->", 239 | "=>", 240 | ",", 241 | ); 242 | Type = "xcode.syntax.keyword"; 243 | }; 244 | }, 245 | 246 | // ---------------------------------------------------------------------------- 247 | // Syntax Coloring 248 | 249 | { 250 | Identifier = "xcode.lang.rust"; 251 | Description = "Rust Coloring"; 252 | BasedOn = "xcode.lang.simpleColoring"; 253 | UsesCLikeIndentation = YES; 254 | IncludeInMenu = YES; 255 | Name = "Rust"; 256 | Syntax = { 257 | Tokenizer = "xcode.lang.rust.lexer.toplevel"; 258 | IncludeRules = ( 259 | "xcode.lang.rust.decorator.document", 260 | "xcode.lang.rust.decorator", 261 | "xcode.lang.rust.macro", 262 | "xcode.lang.rust.block", 263 | "xcode.lang.rust.bracketexpr", 264 | "xcode.lang.rust.parenexpr", 265 | ); 266 | Type = "xcode.syntax.plain"; 267 | }; 268 | }, 269 | 270 | // The following rule returns tokens to the other rules 271 | { 272 | Identifier = "xcode.lang.rust.lexer"; 273 | Syntax = { 274 | IncludeRules = ( 275 | "xcode.lang.rust.comment", 276 | "xcode.lang.rust.comment.singleline", 277 | "xcode.lang.string", 278 | "xcode.lang.character", 279 | "xcode.lang.rust.identifier", 280 | "xcode.lang.number", 281 | "xcode.lang.rust.interestingOperators", 282 | ); 283 | }; 284 | }, 285 | 286 | { 287 | Identifier = "xcode.lang.rust.macro.lexer"; 288 | Syntax = { 289 | IncludeRules = ( 290 | "xcode.lang.rust.comment", 291 | "xcode.lang.rust.comment.singleline", 292 | "xcode.lang.string", 293 | "xcode.lang.character", 294 | "xcode.lang.rust.macro.identifier", 295 | "xcode.lang.number", 296 | ); 297 | }; 298 | }, 299 | 300 | { 301 | Identifier = "xcode.lang.rust.lexer.toplevel"; 302 | Syntax = { 303 | IncludeRules = ( 304 | "xcode.lang.rust.comment", 305 | "xcode.lang.rust.comment.singleline", 306 | "xcode.lang.string", 307 | "xcode.lang.character", 308 | "xcode.lang.rust.type.declaration", 309 | "xcode.lang.rust.function.declaration", 310 | "xcode.lang.rust.macro.name", 311 | "xcode.lang.rust.identifier", 312 | "xcode.lang.number", 313 | ); 314 | }; 315 | }, 316 | 317 | 318 | { 319 | Identifier = "xcode.lang.rust.decorator.document"; 320 | Syntax = { 321 | Start = "#!["; 322 | End = "]"; 323 | Tokenizer = "xcode.lang.rust.macro.lexer"; 324 | Rules = ( 325 | "xcode.lang.rust.macro.identifier", 326 | "xcode.lang.rust.decorator.parameter?", 327 | "xcode.lang.rust.decorator.value?", 328 | ); 329 | Type = "xcode.syntax.preprocessor"; 330 | }; 331 | }, 332 | 333 | { 334 | Identifier = "xcode.lang.rust.decorator"; 335 | Syntax = { 336 | Start = "#["; 337 | End = "]"; 338 | Tokenizer = "xcode.lang.rust.macro.lexer"; 339 | Rules = ( 340 | "xcode.lang.rust.macro.identifier", 341 | "xcode.lang.rust.decorator.parameter?", 342 | "xcode.lang.rust.decorator.value?", 343 | ); 344 | Type = "xcode.syntax.preprocessor"; 345 | }; 346 | }, 347 | 348 | { 349 | Identifier = "xcode.lang.rust.decorator.parameter"; 350 | Syntax = { 351 | Start = "("; 352 | End = ")"; 353 | Tokenizer = "xcode.lang.rust.macro.lexer"; 354 | Rules = ( 355 | "xcode.lang.rust.identifier", 356 | ); 357 | Type = "xcode.syntax.preprocessor"; 358 | }; 359 | }, 360 | 361 | { 362 | Identifier = "xcode.lang.rust.decorator.value"; 363 | Syntax = { 364 | Start = "="; 365 | End = "xcode.lang.string"; 366 | Tokenizer = "xcode.lang.rust.lexer"; 367 | Type = "xcode.syntax.preprocessor"; 368 | }; 369 | }, 370 | 371 | { 372 | Identifier = "xcode.lang.rust.macro"; 373 | Syntax = { 374 | Tokenizer = "xcode.lang.rust.macro.lexer"; 375 | Rules = ( 376 | "xcode.lang.rust.macro.name", 377 | ); 378 | Type = "xcode.syntax.preprocessor"; 379 | }; 380 | }, 381 | 382 | { 383 | Identifier = "xcode.lang.rust.type.declaration"; 384 | Syntax = { 385 | Tokenizer = "xcode.lang.rust.lexer"; 386 | Rules = ( 387 | "type", 388 | "xcode.lang.rust.identifier", 389 | ); 390 | Type = "xcode.syntax.typedef"; 391 | }; 392 | }, 393 | 394 | { 395 | Identifier = "xcode.lang.rust.function.declaration"; 396 | Syntax = { 397 | Tokenizer = "xcode.lang.rust.lexer"; 398 | Rules = ( 399 | "fn", 400 | "xcode.lang.rust.identifier", 401 | "xcode.lang.rust.parenexpr", 402 | "xcode.lang.rust.function.declaration.returntype?", 403 | ); 404 | Type = "xcode.syntax.declaration.function"; 405 | }; 406 | }, 407 | 408 | { 409 | Identifier = "xcode.lang.rust.function.declaration.returntype"; 410 | Syntax = { 411 | Tokenizer = "xcode.lang.rust.lexer"; 412 | Rules = ( 413 | "->", 414 | "xcode.lang.rust.identifier", 415 | ); 416 | }; 417 | }, 418 | 419 | // ---------------------------------------------------------------------------- 420 | // Blocks 421 | 422 | { 423 | Identifier = "xcode.lang.rust.block"; 424 | Syntax = { 425 | Tokenizer = "xcode.lang.rust.lexer"; 426 | Start = "{"; 427 | End = "}"; 428 | Foldable = YES; 429 | Recursive = YES; 430 | IncludeRules = ( 431 | "xcode.lang.rust.bracketexpr", 432 | "xcode.lang.rust.parenexpr", 433 | ); 434 | }; 435 | }, 436 | 437 | { 438 | Identifier = "xcode.lang.rust.parenexpr"; 439 | Syntax = { 440 | Tokenizer = "xcode.lang.rust.lexer"; 441 | Start = "("; 442 | End = ")"; 443 | Recursive = YES; 444 | IncludeRules = ( 445 | "xcode.lang.rust.bracketexpr", 446 | "xcode.lang.rust.block", 447 | ); 448 | }; 449 | }, 450 | 451 | { 452 | Identifier = "xcode.lang.rust.bracketexpr"; 453 | Syntax = { 454 | Tokenizer = "xcode.lang.rust.lexer"; 455 | Start = "["; 456 | End = "]"; 457 | Recursive = YES; 458 | IncludeRules = ( 459 | "xcode.lang.rust.parenexpr", 460 | ); 461 | }; 462 | }, 463 | 464 | { 465 | Identifier = "xcode.lang.rust.comment"; 466 | Syntax = { 467 | Start = "/*"; 468 | End = "*/"; 469 | Foldable = YES; 470 | IncludeRules = ( 471 | "xcode.lang.url", 472 | "xcode.lang.url.mail", 473 | "xcode.lang.comment.mark", 474 | ); 475 | Type = "xcode.syntax.comment"; 476 | }; 477 | }, 478 | 479 | { 480 | Identifier = "xcode.lang.rust.comment.singleline"; 481 | Syntax = { 482 | Start = "//"; 483 | End = "\n"; 484 | IncludeRules = ( 485 | "xcode.lang.url", 486 | "xcode.lang.url.mail", 487 | "xcode.lang.comment.mark", 488 | ); 489 | Type = "xcode.syntax.comment"; 490 | }; 491 | }, 492 | 493 | ) 494 | -------------------------------------------------------------------------------- /Rust.xcspec: -------------------------------------------------------------------------------- 1 | /* 2 | * Rust.xcspec: Xcode file type for Rust 3 | * 4 | */ 5 | 6 | ( 7 | { 8 | Type = FileType; 9 | Identifier = sourcecode.rust; 10 | BasedOn = sourcecode; 11 | Name = "Rust file"; 12 | Extensions = ( rs ); 13 | Language = "xcode.lang.rust"; 14 | } 15 | ) -------------------------------------------------------------------------------- /install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Created by Alex Karahalios on 6/12/11 4 | # Edited by Brian Reinhart on 08/02/2012 . 5 | # Edited for Rust by Jeong YunWon on 2014/06/03 6 | # 7 | # Updates Xcode and to support Rust language for editing 8 | # 9 | 10 | # Path were this script is located 11 | # 12 | SCRIPT_PATH="$(dirname "$BASH_SOURCE")" 13 | 14 | # Set up path for PlistBuddy helper application which can add elements to Plist files 15 | # 16 | PLISTBUDDY=/usr/libexec/PlistBuddy 17 | 18 | # Filename path private framework we need to modify 19 | # 20 | #DVTFOUNDATION_PATH="/Developer/Library/PrivateFrameworks/DVTFoundation.framework/Versions/A/Resources/" 21 | #DVTFOUNDATION_PATH="/XCode4.3/Library/PrivateFrameworks/DVTFoundation.framework/Versions/A/Resources/" 22 | 23 | # This framework is found withing the Xcode.app package and is used when Xcode is a monolithic 24 | # install (all contained in Xcode.app) 25 | # 26 | DVTFOUNDATION_PATH="/Applications/Xcode.app/Contents/SharedFrameworks/DVTFoundation.framework/Versions/A/Resources/" 27 | 28 | # Create Plist file of additional languages to add to 'DVTFoundation.xcplugindata' 29 | # 30 | cat >AdditionalLanguages.plist < 32 | 33 | 34 | 35 | Xcode.SourceCodeLanguage.Rust 36 | 37 | languageSpecification 38 | xcode.lang.rust 39 | fileDataType 40 | 41 | 42 | identifier 43 | com.apple.xcode.rust-source 44 | 45 | 46 | id 47 | Xcode.SourceCodeLanguage.Rust 48 | point 49 | Xcode.SourceCodeLanguage 50 | languageName 51 | Rust 52 | version 53 | 1.0 54 | conformsTo 55 | 56 | 57 | identifier 58 | Xcode.SourceCodeLanguage.Generic 59 | 60 | 61 | name 62 | Rust Language 63 | 64 | 65 | 66 | EOF 67 | 68 | # Now merge in the additonal languages to DVTFoundation.xcplugindata 69 | # 70 | $PLISTBUDDY "$DVTFOUNDATION_PATH/DVTFoundation.xcplugindata" -c 'Merge AdditionalLanguages.plist plug-in:extensions' 71 | 72 | # Get rid of the AdditionalLanguages.plist since it was just temporary 73 | # 74 | rm -f AdditionalLanguages.plist 75 | 76 | # Copy in the xclangspecs for the languages (assumes in same directory as this shell script) 77 | # 78 | cp "$SCRIPT_PATH/Rust.xclangspec" "$DVTFOUNDATION_PATH" 79 | 80 | # Remove any cached Xcode plugins 81 | # 82 | rm -f /private/var/folders/*/*/*/com.apple.DeveloperTools/*/Xcode/PlugInCache.xcplugincache 83 | --------------------------------------------------------------------------------