diff --git a/utils/textmate/Syntaxes/Carbon.plist b/utils/textmate/Syntaxes/Carbon.plist deleted file mode 100644 index b532b89574c6e..0000000000000 --- a/utils/textmate/Syntaxes/Carbon.plist +++ /dev/null @@ -1,157 +0,0 @@ - - - - - - - - - name - carbon - uuid - 04F7F7E3-D5EE-40A4-9899-53CD34D28276 - scopeName - source.carbon - fileTypes - - carbon - - - - foldingStartMarker - \{\s*$ - foldingStopMarker - ^\s*\} - - - patterns - - - - begin - (^[ \t]+)?(?=//) - end - (?!\G) - patterns - - - name - comment.line.carbon - begin - // - end - $ - - - - - - name - keyword.control.carbon - match - \b(break|case|continue|default|else|if|for|match|return|returned|then|while)\b - - - - name - keyword.other.carbon - match - \b(abstract|adapt|addr|alias|and|api|as|auto|base|choice|class|constraint|destructor|extend|final|fn|forall|friend|impl|impls|import|in|interface|let|library|like|namespace|not|observe|or|override|package|partial|private|protected|require|Self|template|type|var|virtual|where|_)\b - - - - name - storage.type.carbon - match - \b(As|bool|Carbon\.Int|Carbon\.UInt|f16|f32|f64|f128|i8|i16|i32|i64|i128|i256|Slice|String|StringView|type|u8|u16|u32|u64|u128|u256)\b - - - - name - keyword.other.carbon - match - \b(true|false)\b - - - - name - string.quoted.triple.carbon - begin - '''([^\s'#]*\n)? - end - ''' - beginCaptures - - 1 - - name - constant.character.escape.carbon - - - patterns - - - include - #string_escapes - - - - - - name - string.quoted.double.carbon - begin - " - end - " - - patterns - - - include - #string_escapes - - - - - - name - constant.numeric.carbon - match - 0x[_0-9A-F]+(\.[_0-9A-F]+(p[-+]?[1-9][0-9]*)?)? - - - - name - constant.numeric.carbon - match - 0b[_01]+ - - - - name - constant.numeric.carbon - match - [1-9][_0-9]*(\.[_0-9]+(e[-+]?[1-9][0-9]*)?)? - - - - - repository - - - string_escapes - - name - constant.character.escape.carbon - match - \\([tnr'"0\0]|x[0-9A-F]{2}|u\{[0-9A-F]{4,}\}) - - - - diff --git a/utils/textmate/Syntaxes/carbon.tmLanguage.json b/utils/textmate/Syntaxes/carbon.tmLanguage.json new file mode 100644 index 0000000000000..de3d06bf8b02c --- /dev/null +++ b/utils/textmate/Syntaxes/carbon.tmLanguage.json @@ -0,0 +1,201 @@ +// Part of the Carbon Language project, under the Apache License v2.0 with LLVM +// Exceptions. See /LICENSE for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +{ + "$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json", + "name": "carbon", + "foldingStartMarker": "\\{\\s*$", + "foldingStopMarker": "^\\s*\\}", + "fileTypes": ["carbon"], + "patterns": [ + { + "include": "#comments" + }, + { + "include": "#operators" + }, + { + "include": "#special-keywords" + }, + { + "include": "#numbers" + }, + { + "include": "#reserved-words" + }, + { + "include": "#operator-dedicated-keywords-statements" + }, + { + "include": "#ctrl-statements" + }, + { + "include": "#true-false" + }, + { + "include": "#functions" + }, + { + "name": "string.quoted.triple.carbon", + "begin": "'''([^\\s'#]*\\n)?", + "end": "'''", + "beginCaptures": { + "1": { + "name": "constant.character.escape.carbon" + } + }, + "patterns": [ + { + "include": "#string_escapes" + } + ] + }, + { + "name": "string.quoted.double.carbon", + "begin": "\"", + "end": "\"", + "patterns": [ + { + "include": "#string_escapes" + } + ] + }, + { + "include": "#customs" + } + ], + "repository": { + "operators": { + "patterns": [ + { + "name": "keyword.operator.carbon", + "match": "\\b(\\+|-|\\*|/|!)\\b" + } + ] + }, + "comments": { + "patterns": [ + { + "begin": "(^[ \\t]+)?(?=//)", + "end": "(?!\\G)", + "patterns": [ + { + "name": "comment.line.carbon", + "begin": "//", + "end": "$" + } + ] + } + ] + }, + "string_escapes": { + "patterns": [ + { + "name": "constant.character.escape.carbon", + "match": "\\\\([tnr'\"0\\0]|x[0-9A-F]{2}|u\\{[0-9A-F]{4,}\\})" + } + ] + }, + "special-keywords": { + "patterns": [ + { + "name": "keyword.control.carbon", + "match": "\\b(break|case|continue|default|else|if|for|match|return|returned|then|while)\\b" + } + ] + }, + "operator-dedicated-keywords-statements": { + "patterns": [ + { + "name": "keyword.other.carbon", + "match": "\\b(abstract|adapt|addr|alias|and|api|as|auto|base|choice|class|constraint|destructor|extend|final|fn|forall|friend|impl|impls|import|in|interface|let|library|like|namespace|not|observe|or|override|package|partial|private|protected|require|Self|template|type|var|virtual|where|_)\\b" + } + ] + }, + "reserved-words": { + "patterns": [ + { + "name": "support.type.carbon", + "match": "\\b(As|bool|Carbon\\.Int|Carbon\\.UInt|f16|f32|f64|f128|i8|i16|i32|i64|i128|i256|Slice|String|StringView|type|u8|u16|u32|u64|u128|u256)\\b" + } + ] + }, + "true-false": { + "patterns": [ + { + "name": "constant.language.carbon", + "match": "\\b(true|false)\\b" + } + ] + }, + "functions": { + "patterns": [ + { + "name": "support.function.carbon", + "match": "\\b[a-zA-Z]+\\s*\\(" + } + ] + }, + "customs": { + "patterns": [ + { + "name": "support.class.carbon", + "match": "(?<=\\bpackage\\s)\\w+" + }, + { + "name": "support.variable.carbon", + "match": "(?<=\\s*\\.)\\w+" + }, + { + "name": "support.variable.carbon", + "match": "(?<=\\bas\\s)\\w+" + }, + { + "name": "support.variable.carbon", + "match": "\\w+(?=\\s*:)" + }, + { + "name": "support.variable.carbon", + "match": "(?<=\\blet\\s)\\w+" + }, + { + "name": "support.variable.carbon", + "match": "(?<=\\bvar\\s)\\w+" + }, + { + "name": "support.function.carbon", + "match": "(?<=\\bfn\\s)\\w+" + }, + { + "name": "support.other.carbon", + "match": "(?<=\\bimpl\\s)\\w+" + }, + { + "name": "support.type.property-name.carbon", + "match": "(?<=\\bimport\\s)\\w+" + }, + { + "name": "support.class.carbon", + "match": "(?<=\\bclass\\s)\\w+" + } + ] + }, + "numbers": { + "patterns": [ + { + "name": "constant.numeric.carbon", + "match": "0x[_0-9A-F]+(\\.[_0-9A-F]+(p[-+]?[1-9][0-9]*)?)?" + }, + { + "name": "constant.numeric.carbon", + "match": "0b[_01]+" + }, + { + "name": "constant.numeric.carbon", + "match": "[1-9][_0-9]*(\\.[_0-9]+(e[-+]?[1-9][0-9]*)?)?" + } + ] + } + }, + "scopeName": "source.carbon" +} diff --git a/utils/vscode/Carbon.plist b/utils/vscode/Carbon.plist deleted file mode 120000 index 7699042862a6a..0000000000000 --- a/utils/vscode/Carbon.plist +++ /dev/null @@ -1 +0,0 @@ -../textmate/Syntaxes/Carbon.plist \ No newline at end of file diff --git a/utils/vscode/carbon.tmLanguage.json b/utils/vscode/carbon.tmLanguage.json new file mode 120000 index 0000000000000..d5c68e61e9e7a --- /dev/null +++ b/utils/vscode/carbon.tmLanguage.json @@ -0,0 +1 @@ +../textmate/Syntaxes/carbon.tmLanguage.json \ No newline at end of file diff --git a/utils/vscode/language-configuration.json b/utils/vscode/language-configuration.json index 4f505bb76585f..cc458075583d0 100644 --- a/utils/vscode/language-configuration.json +++ b/utils/vscode/language-configuration.json @@ -6,19 +6,27 @@ "comments": { "lineComment": "//" }, + // Symbols used as brackets. "brackets": [ - ["(", ")"], + ["{", "}"], ["[", "]"], - ["{", "}"] + ["(", ")"] ], + // Symbols that are auto closed when typing. "autoClosingPairs": [ - ["(", ")"], + ["{", "}"], ["[", "]"], - ["{", "}"] + ["(", ")"], + ["\"", "\""], + ["'", "'"] ], + // Symbols that can be used to surround a selection. "surroundingPairs": [ - ["(", ")"], + ["{", "}"], ["[", "]"], - ["{", "}"] + ["(", ")"], + ["\"", "\""], + ["'", "'"], + ["'''", "'''"] ] } diff --git a/utils/vscode/package.json b/utils/vscode/package.json index f032a94495181..a80371eacfed5 100644 --- a/utils/vscode/package.json +++ b/utils/vscode/package.json @@ -2,7 +2,7 @@ "name": "carbon-lang", "displayName": "carbon-lang", "description": "Carbon Language support", - "version": "0.0.1", + "version": "0.0.2", "repository": { "url": "https://github.com/carbon-language/carbon-lang" }, @@ -18,7 +18,9 @@ "languages": [ { "id": "carbon", - "aliases": [], + "aliases": [ + "Carbon" + ], "extensions": [ ".carbon" ], @@ -29,7 +31,7 @@ { "language": "carbon", "scopeName": "source.carbon", - "path": "Carbon.plist" + "path": "./carbon.tmLanguage.json" } ] },