Skip to content

Commit

Permalink
Simplify class and module grammar for more consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
vinistock committed Jul 5, 2024
1 parent a4391c6 commit b7b2961
Showing 1 changed file with 22 additions and 24 deletions.
46 changes: 22 additions & 24 deletions vscode/grammars/ruby.cson.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,20 +51,21 @@
"2": {
"name": "entity.name.type.class.ruby"
},
"4": {
"name": "entity.other.inherited-class.ruby"
},
"5": {
"name": "punctuation.separator.namespace.ruby"
},
"7": {
"name": "punctuation.separator.inheritance.ruby"
},
"6": {
"name": "variable.other.object.ruby"
"8": {
"name": "entity.other.inherited-class.ruby"
},
"7": {
"name": "punctuation.definition.variable.ruby"
"11": {
"name": "punctuation.separator.namespace.ruby"
}
},
"match": "(?x)\n^\\s*(class)\\s+\n(\n (\n [.a-zA-Z0-9_:]+\n (\\s*(<)\\s*[.a-zA-Z0-9_:]+)? # class A < B\n )\n |\n ((<<)\\s*[.a-zA-Z0-9_:]+) # class << C\n)",
"comment": "class Namespace::ClassName < OtherNamespace::OtherClassName",
"match": "(class)\\s*(([a-zA-Z0-9_]+)((::)[a-zA-Z0-9_]+)*)\\s*((<)\\s*(([a-zA-Z0-9_]+)((::)[a-zA-Z0-9_]+)*))?",
"name": "meta.class.ruby"
},
{
Expand All @@ -75,27 +76,24 @@
"2": {
"name": "entity.name.type.module.ruby"
},
"3": {
"name": "entity.other.inherited-class.module.first.ruby"
},
"4": {
"name": "punctuation.separator.inheritance.ruby"
},
"5": {
"name": "entity.other.inherited-class.module.second.ruby"
},
"6": {
"name": "punctuation.separator.inheritance.ruby"
},
"7": {
"name": "entity.other.inherited-class.module.third.ruby"
"name": "punctuation.separator.namespace.ruby"
}
},
"match": "(module)\\s*(([a-zA-Z0-9_]+)((::)[a-zA-Z0-9_]+)*)",
"name": "meta.module.ruby"
},
{
"captures": {
"1": {
"name": "keyword.control.class.ruby"
},
"8": {
"2": {
"name": "punctuation.separator.inheritance.ruby"
}
},
"match": "(?x)\n^\\s*(module)\\s+\n(\n ([A-Z]\\w*(::))?\n ([A-Z]\\w*(::))?\n ([A-Z]\\w*(::))*\n [A-Z]\\w*\n)",
"name": "meta.module.ruby"
"match": "(class)\\s*(<<)\\s*",
"name": "meta.class.ruby"
},
{
"comment": "else if is a common mistake carried over from other languages. it works if you put in a second end, but it’s never what you want.",
Expand Down

0 comments on commit b7b2961

Please sign in to comment.