mirror of
https://github.com/atom/atom.git
synced 2026-01-25 14:59:03 -05:00
Merge pull request #18257 from atom/mb-bundle-rust-grammar
Provide built-in Rust support using Tree-sitter
This commit is contained in:
14
package-lock.json
generated
14
package-lock.json
generated
@@ -3236,6 +3236,12 @@
|
||||
"version": "https://www.atom.io/api/packages/language-ruby-on-rails/versions/0.25.3/tarball",
|
||||
"integrity": "sha512-uI4ItSsq1J0/5gBblVgLv69C8TzWMcAoL19H8iFuosWWDRUsh9va1PrPMLeSNnNbnOYkw2fE53fqLlJjrgxiGw=="
|
||||
},
|
||||
"language-rust-bundled": {
|
||||
"version": "file:packages/language-rust-bundled",
|
||||
"requires": {
|
||||
"tree-sitter-rust": "^0.13.4"
|
||||
}
|
||||
},
|
||||
"language-sass": {
|
||||
"version": "https://www.atom.io/api/packages/language-sass/versions/0.62.0/tarball",
|
||||
"integrity": "sha512-qaH8BDNBOkpbR4thmcRimEphnrzzhpDxeQM+WCM3Unp3a8r3aV2xcY9LlvbZxpclz8TOUyvuc5qgj1YI//ge9w=="
|
||||
@@ -5684,6 +5690,14 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"tree-sitter-rust": {
|
||||
"version": "0.13.4",
|
||||
"resolved": "https://registry.npmjs.org/tree-sitter-rust/-/tree-sitter-rust-0.13.4.tgz",
|
||||
"integrity": "sha512-mxlGjCGEzK1sAQsmTnwM0CMTEgZmUMs75ivCH7y26byKMFTZpdv/QIUOI5Dboag5m8BpvI0nRpBE8gDqfrsbEw==",
|
||||
"requires": {
|
||||
"nan": "^2.8.0"
|
||||
}
|
||||
},
|
||||
"tree-sitter-typescript": {
|
||||
"version": "0.13.3",
|
||||
"resolved": "https://registry.npmjs.org/tree-sitter-typescript/-/tree-sitter-typescript-0.13.3.tgz",
|
||||
|
||||
@@ -102,6 +102,7 @@
|
||||
"language-python": "https://www.atom.io/api/packages/language-python/versions/0.51.6/tarball",
|
||||
"language-ruby": "https://www.atom.io/api/packages/language-ruby/versions/0.72.11/tarball",
|
||||
"language-ruby-on-rails": "https://www.atom.io/api/packages/language-ruby-on-rails/versions/0.25.3/tarball",
|
||||
"language-rust-bundled": "file:packages/language-rust-bundled",
|
||||
"language-sass": "https://www.atom.io/api/packages/language-sass/versions/0.62.0/tarball",
|
||||
"language-shellscript": "https://www.atom.io/api/packages/language-shellscript/versions/0.27.8/tarball",
|
||||
"language-source": "https://www.atom.io/api/packages/language-source/versions/0.9.0/tarball",
|
||||
@@ -252,6 +253,7 @@
|
||||
"language-python": "0.51.6",
|
||||
"language-ruby": "0.72.11",
|
||||
"language-ruby-on-rails": "0.25.3",
|
||||
"language-rust-bundled": "file:./packages/language-rust-bundled",
|
||||
"language-sass": "0.62.0",
|
||||
"language-shellscript": "0.27.8",
|
||||
"language-source": "0.9.0",
|
||||
|
||||
3
packages/language-rust-bundled/README.md
Normal file
3
packages/language-rust-bundled/README.md
Normal file
@@ -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
packages/language-rust-bundled/grammars/tree-sitter-rust.cson
Normal file
150
packages/language-rust-bundled/grammars/tree-sitter-rust.cson
Normal file
@@ -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'
|
||||
18
packages/language-rust-bundled/package.json
Normal file
18
packages/language-rust-bundled/package.json
Normal file
@@ -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"
|
||||
}
|
||||
}
|
||||
24
packages/language-rust-bundled/settings/rust.cson
Normal file
24
packages/language-rust-bundled/settings/rust.cson
Normal file
@@ -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: [
|
||||
'()'
|
||||
'[]'
|
||||
'{}'
|
||||
'<>'
|
||||
'""'
|
||||
'``'
|
||||
]
|
||||
Reference in New Issue
Block a user