diff --git a/grammars/rust.cson b/grammars/rust.cson index 53af9fa..d2afa20 100644 --- a/grammars/rust.cson +++ b/grammars/rust.cson @@ -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-z][_A-Za-z0-9]*|_[_A-Za-z0-9]+)\\b' + } 'type_params': { 'comment': 'Type parameters' 'name': 'meta.type_params.rust' @@ -159,11 +164,40 @@ { 'include': '#std_types' } { 'include': '#std_traits' } { 'include': '#type_params' } + # { 'include': '#type' } ] } } 'patterns': [ + # 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' + } + { 'include': '#type' } + ] + } # Comments { 'include': '#block_doc_comment' } { 'include': '#block_comment' } @@ -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' - } - ] - } ] diff --git a/spec/rust-spec.coffee b/spec/rust-spec.coffee index 3cbc154..4ee5f05 100644 --- a/spec/rust-spec.coffee +++ b/spec/rust-spec.coffee @@ -539,8 +539,8 @@ describe 'Rust grammar', -> struct Foo where text { } trait Foo : C where { } ''') - expect(tokens[0][6]).toEqual value: 'where', scopes: ['source.rust', 'keyword.other.where.rust'] - expect(tokens[1][8]).toEqual value: 'where', scopes: ['source.rust', 'keyword.other.where.rust'] + expect(tokens[0][7]).toEqual value: 'where', scopes: ['source.rust', 'keyword.other.where.rust'] + expect(tokens[1][11]).toEqual value: 'where', scopes: ['source.rust', 'keyword.other.where.rust'] expect(tokens[3][8]).toEqual value: 'where', scopes: ['source.rust', 'keyword.other.where.rust'] expect(tokens[5][7]).toEqual value: 'where', scopes: ['source.rust', 'keyword.other.where.rust'] expect(tokens[6][7]).toEqual value: 'where', scopes: ['source.rust', 'keyword.other.where.rust']