forked from atom/atom
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request atom#18257 from atom/mb-bundle-rust-grammar
Provide built-in Rust support using Tree-sitter
- Loading branch information
Showing
6 changed files
with
211 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# language-rust | ||
|
||
This package provides Rust syntax highlighting in Atom based on syntax trees provided by [tree-sitter-rust](https://github.com/tree-sitter/tree-sitter-rust). |
150 changes: 150 additions & 0 deletions
150
packages/language-rust-bundled/grammars/tree-sitter-rust.cson
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
name: 'Rust' | ||
scopeName: 'source.rust' | ||
type: 'tree-sitter' | ||
parser: 'tree-sitter-rust' | ||
|
||
fileTypes: [ | ||
'rs' | ||
] | ||
|
||
comments: | ||
start: '// ' | ||
|
||
folds: [ | ||
{ | ||
type: 'block_comment' | ||
} | ||
{ | ||
start: {index: 0, type: '{'} | ||
end: {index: -1, type: '}'} | ||
} | ||
{ | ||
start: {index: 0, type: '['} | ||
end: {index: -1, type: ']'} | ||
} | ||
{ | ||
start: {index: 0, type: '('} | ||
end: {index: -1, type: ')'} | ||
} | ||
{ | ||
start: {index: 0, type: '<'} | ||
end: {index: -1, type: '>'} | ||
} | ||
] | ||
|
||
scopes: | ||
'type_identifier': 'support.type' | ||
'primitive_type': 'support.type' | ||
'field_identifier': 'variable.other.member' | ||
|
||
'line_comment': 'comment.block' | ||
'block_comment': 'comment.block' | ||
|
||
'identifier': [ | ||
{match: '^[A-Z\\d_]+$', scopes: 'constant.other'} | ||
] | ||
|
||
''' | ||
identifier, | ||
call_expression > identifier, | ||
call_expression > field_expression > field_identifier, | ||
call_expression > scoped_identifier > identifier:nth-child(2) | ||
''': [ | ||
{match: '^[A-Z]', scopes: 'entity.name.class'} | ||
] | ||
|
||
''' | ||
macro_invocation > identifier, | ||
macro_definition > identifier, | ||
call_expression > identifier, | ||
call_expression > field_expression > field_identifier, | ||
call_expression > scoped_identifier > identifier:nth-child(2), | ||
generic_function > identifier, | ||
generic_function > field_expression > field_identifier, | ||
generic_function > scoped_identifier > identifier, | ||
function_item > identifier, | ||
function_signature_item > identifier, | ||
''': 'entity.name.function' | ||
|
||
''' | ||
use_list > self, | ||
scoped_use_list > self, | ||
scoped_identifier> self, | ||
use_list > crate, | ||
scoped_use_list > crate, | ||
scoped_identifier> crate, | ||
use_list > super, | ||
scoped_use_list > super, | ||
scoped_identifier> super | ||
''': 'keyword.control' | ||
|
||
''' | ||
use_wildcard > identifier:nth-child(0), | ||
scoped_type_identifier > identifier:nth-child(0), | ||
scoped_type_identifier > scoped_identifier:nth-child(0) > identifier, | ||
scoped_identifier > identifier:nth-child(0), | ||
scoped_identifier > scoped_identifier:nth-child(0) > identifier, | ||
use_declaration > identifier, | ||
use_declaration > scoped_identifier > identifier, | ||
use_list > identifier, | ||
use_list > scoped_identifier > identifier, | ||
meta_item > identifier | ||
''': [ | ||
{match: '^[A-Z]', scopes: 'support.type'} | ||
] | ||
|
||
'lifetime > identifier': 'constant.variable' | ||
|
||
'"let"': 'storage.modifier' | ||
'"const"': 'storage.modifier' | ||
'"static"': 'storage.modifier' | ||
'"extern"': 'storage.modifier' | ||
'"fn"': 'storage.modifier' | ||
'"type"': 'storage.modifier' | ||
'"impl"': 'storage.modifier' | ||
'"dyn"': 'storage.modifier' | ||
'"trait"': 'storage.modifier' | ||
'"mod"': 'storage.modifier' | ||
'"pub"': 'storage.modifier' | ||
'"crate"': 'storage.modifier' | ||
'"default"': 'storage.modifier' | ||
'"struct"': 'storage.modifier' | ||
'"enum"': 'storage.modifier' | ||
'"union"': 'storage.modifier' | ||
'mutable_specifier': 'storage.modifier' | ||
|
||
'"unsafe"': 'keyword.control' | ||
'"use"': 'keyword.control' | ||
'"match"': 'keyword.control' | ||
'"if"': 'keyword.control' | ||
'"in"': 'keyword.control' | ||
'"else"': 'keyword.control' | ||
'"move"': 'keyword.control' | ||
'"while"': 'keyword.control' | ||
'"loop"': 'keyword.control' | ||
'"for"': 'keyword.control' | ||
'"let"': 'keyword.control' | ||
'"return"': 'keyword.control' | ||
'"continue"': 'keyword.control' | ||
'"break"': 'keyword.control' | ||
'"where"': 'keyword.control' | ||
'"ref"': 'keyword.control' | ||
'"macro_rules!"': 'keyword.control' | ||
|
||
'"as"': 'keyword.operator' | ||
|
||
'char_literal': 'string.quoted.single' | ||
'string_literal': 'string.quoted.double' | ||
'raw_string_literal': 'string.quoted.other' | ||
'boolean_literal': 'constant.language.boolean' | ||
'integer_literal': 'constant.numeric.decimal' | ||
'float_literal': 'constant.numeric.decimal' | ||
'escape_sequence': 'constant.character.escape' | ||
|
||
'attribute_item, inner_attribute_item': 'entity.other.attribute-name' | ||
|
||
''' | ||
"as", | ||
"*", | ||
"&", | ||
''': 'keyword.operator' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"name": "language-rust-bundled", | ||
"version": "0.1.0", | ||
"description": "Rust support for Atom", | ||
"keywords": [ | ||
"language", | ||
"grammar", | ||
"rust" | ||
], | ||
"repository": "https://github.com/atom/atom", | ||
"license": "MIT", | ||
"dependencies": { | ||
"tree-sitter-rust": "^0.13.4" | ||
}, | ||
"engines": { | ||
"atom": ">=1.0.0 <2.0.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
'.source.rust': | ||
'editor': | ||
'commentStart': '// ' | ||
'increaseIndentPattern': '(?x) | ||
^ .* \\{ [^}"\']* $ | ||
|^ .* \\( [^\\)"\']* $ | ||
|^ \\s* \\{ \\} $ | ||
' | ||
'decreaseIndentPattern': '(?x) | ||
^ \\s* (\\s* /[*] .* [*]/ \\s*)* \\} | ||
|^ \\s* (\\s* /[*] .* [*]/ \\s*)* \\) | ||
' | ||
'tabLength': 4 | ||
'softTabs': true | ||
'preferredLineLength': 99 | ||
'bracket-matcher': | ||
autocompleteCharacters: [ | ||
'()' | ||
'[]' | ||
'{}' | ||
'<>' | ||
'""' | ||
'``' | ||
] |