Skip to content
This repository has been archived by the owner on Jan 25, 2022. It is now read-only.

Added impl capture. #96

Merged
merged 6 commits into from
May 2, 2017
Merged
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 34 additions & 27 deletions grammars/rust.cson
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,11 @@
'name': 'support.type.std.rust'
'match': '\\b(ToOwned|ToString)\\b'
}
'type': {
'comment': 'A type'
'name': 'entity.name.type.rust'
'match': '\\b[A-Za-z0-9_]+\\b'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is wrong regex because it matches for _, 0 and etc.

The correct is \\b([A-Za-z][A-Za-z0-9_]*|_[A-Za-z][A-Za-z0-9_]*)\\b.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The correct is \\b([A-Za-z][_A-Za-z0-9]*|_[_A-Za-z0-9]+)\\b

}
'type_params': {
'comment': 'Type parameters'
'name': 'meta.type_params.rust'
Expand All @@ -159,11 +164,40 @@
{ 'include': '#std_types' }
{ 'include': '#std_traits' }
{ 'include': '#type_params' }
{ 'include': '#type' }
]
}
}

'patterns': [
# Implementation
{
'comment': 'Implementation'
'begin': '\\b(impl)'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be \\b(impl)\\b because otherwise it would match implementation.

'end': '\\{'
'beginCaptures': {
'1': { 'name': 'storage.type.rust' }
}
'patterns': [
{ 'include': '#block_comment' }
{ 'include': '#line_comment' }
{ 'include': '#sigils' }
{ 'include': '#mut' }
{ 'include': '#ref_lifetime' }
{ 'include': '#core_types' }
{ 'include': '#core_marker' }
{ 'include': '#core_traits' }
{ 'include': '#std_types' }
{ 'include': '#std_traits' }
{ 'include': '#type_params' }
{ 'include': '#where' }
{
'name': 'storage.type.rust'
'match': '\\bfor\\b'
}
{ 'include': '#type' }
]
}
# Comments
{ 'include': '#block_doc_comment' }
{ 'include': '#block_comment' }
Expand Down Expand Up @@ -403,31 +437,4 @@
{ 'include': '#type_params' }
]
}
# Implementation
{
'comment': 'Implementation'
'begin': '\\b(impl)\\b'
'end': '\\{'
'beginCaptures': {
'1': { 'name': 'storage.type.rust' }
}
'patterns': [
{ 'include': '#block_comment' }
{ 'include': '#line_comment' }
{ 'include': '#sigils' }
{ 'include': '#mut' }
{ 'include': '#ref_lifetime' }
{ 'include': '#core_types' }
{ 'include': '#core_marker' }
{ 'include': '#core_traits' }
{ 'include': '#std_types' }
{ 'include': '#std_traits' }
{ 'include': '#type_params' }
{ 'include': '#where' }
{
'name': 'storage.type.rust'
'match': '\\bfor\\b'
}
]
}
]