Skip to content

vscode: fix tmGrammar issues around non-controlflow keywords #6497

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 8, 2020
Merged
Changes from all 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
14 changes: 7 additions & 7 deletions editors/code/rust.tmGrammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@
"match": "(mod)\\s+((?:r#(?!crate|[Ss]elf|super))?[a-z][A-Za-z0-9_]*)",
"captures": {
"1": {
"name": "keyword.control.rust"
"name": "storage.type.rust"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same as extern. @dustypomerleau, @matklad?

Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment, I think this should be storage.modifier

},
"2": {
"name": "entity.name.module.rust"
Expand All @@ -180,7 +180,7 @@
"begin": "\\b(extern)\\s+(crate)",
"beginCaptures": {
"1": {
"name": "keyword.control.rust"
"name": "storage.type.rust"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've just realized. This might be wrong. I think this should've been keyword.other.rust. The extern keyword doesn't signify any storage here.

Copy link
Contributor

@dustypomerleau dustypomerleau Nov 8, 2020

Choose a reason for hiding this comment

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

I have never been clear on precisely what constitutes storage in Textmate grammars. The official documentation states that storage should be used for 'things relating to "storage,"' which is a little bit circular for the uninitiated. @bjorn3 had specific opinions when I originally proposed the grammar, so perhaps could weigh in here. My impression is that storage applies to situations where memory is allocated, but there is a lot of gray area there. CC: @georgewfraser.

I'm happy to merge a reverting PR on these two scopes, but let's hold off for some consensus. As an aside, the grammar probably needs tests so that it doesn't become a brittle house of cards when others contribute. I'll have a look at implementing PanAeon's approach when things slow down on the issue front.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think this should be storage.modifier. See https://macromates.com/manual/en/language_grammars

},
"2": {
"name": "keyword.other.crate.rust"
Expand Down Expand Up @@ -213,7 +213,7 @@
"begin": "\\b(use)\\s",
"beginCaptures": {
"1": {
"name": "keyword.control.rust"
"name": "keyword.other.rust"
}
},
"end": ";",
Expand Down Expand Up @@ -342,7 +342,7 @@
"match": "\\b(const)\\s+([A-Z][A-Za-z0-9_]*)\\b",
"captures": {
"1": {
"name": "keyword.control.rust"
"name": "storage.type.rust"
},
"2": {
"name": "constant.other.caps.rust"
Expand Down Expand Up @@ -450,7 +450,7 @@
"begin": "\\b(fn)\\s+((?:r#(?!crate|[Ss]elf|super))?[A-Za-z0-9_]+)((\\()|(<))",
"beginCaptures": {
"1": {
"name": "keyword.control.fn.rust"
"name": "keyword.other.fn.rust"
},
"2": {
"name": "entity.name.function.rust"
Expand Down Expand Up @@ -643,7 +643,7 @@
{
"comment": "control flow keywords",
"name": "keyword.control.rust",
"match": "\\b(async|await|break|continue|do|else|for|if|loop|match|move|return|try|where|while|yield)\\b"
"match": "\\b(await|break|continue|do|else|for|if|loop|match|return|try|while|yield)\\b"
},
{
"comment": "storage keywords",
Expand All @@ -658,7 +658,7 @@
{
"comment": "other keywords",
"name": "keyword.other.rust",
"match": "\\b(as|become|box|dyn|final|impl|in|override|priv|pub|ref|typeof|union|unsafe|unsized|use|virtual)\\b"
"match": "\\b(as|async|become|box|dyn|move|final|impl|in|override|priv|pub|ref|typeof|union|unsafe|unsized|use|virtual|where)\\b"
},
{
"comment": "fn",
Expand Down