FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Add scopes for a number of items. · blacknode404/language-ruby@e9db616 · GitHub

Commit e9db616

Browse files
Add scopes for a number of items.
(Operators, punctuation, global variables, and method parameters. Also further distinguishes the scope names of strings so that they can be treated differently from one another. Used the TM-style grammar as reference.)
1 parent b6de11b commit e9db616

1 file changed

Lines changed: 67 additions & 2 deletions

File tree

‎grammars/tree-sitter-ruby.cson‎

Lines changed: 67 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ scopes:
129129
{match: '^[A-Z_0-9]+$', scopes: 'variable.constant'}
130130
'entity.name.type.class'
131131
]
132+
'global_variable': 'variable.other.readwrite.global'
132133
'superclass > constant': 'entity.other.inherited-class'
133134

134135
'identifier': [
@@ -157,7 +158,7 @@ scopes:
157158
]
158159

159160
'block_parameters > identifier': 'variable.other.block'
160-
'method_parameters > identifier': 'variable.parameter.function'
161+
'method_parameters > identifier, optional_parameter > identifier': 'variable.parameter.function'
161162
'keyword_parameter > identifier:nth-child(0)': 'constant.other.symbol'
162163
'class_variable': 'variable.other.object.property'
163164
'instance_variable': 'variable.other.object.property'
@@ -168,7 +169,71 @@ scopes:
168169
'regex': 'string.regexp'
169170
'float': 'constant.numeric'
170171
'integer': 'constant.numeric'
171-
'string, bare_string, subshell, heredoc_beginning, heredoc_body': 'string'
172+
173+
'string': [
174+
{match: '^"', scopes: 'string.quoted.double.interpolated'}
175+
{match: "^'", scopes: 'string.quoted.single'}
176+
'string'
177+
]
178+
179+
# Quote delimiters are the only two children of these kinds of strings. If
180+
# this changes in the tree-sitter parser in the future, these selectors will
181+
# need updating.
182+
"string > '\"':nth-child(0)": 'punctuation.definition.string.begin'
183+
"string > '\"':nth-child(1)": 'punctuation.definition.string.end'
184+
'string > "\'":nth-child(0)': 'punctuation.definition.string.begin'
185+
'string > "\'":nth-child(1)': 'punctuation.definition.string.end'
186+
187+
'heredoc_beginning, heredoc_body': 'string.unquoted.heredoc.interpolated'
188+
'subshell': 'string.quoted.subshell.interpolated'
189+
'bare_string': 'string.unquoted.other'
190+
191+
'"="': 'keyword.operator.assignment'
192+
193+
'"+="': 'keyword.operator.assignment.augmented'
194+
'"-="': 'keyword.operator.assignment.augmented'
195+
'"*="': 'keyword.operator.assignment.augmented'
196+
'"/="': 'keyword.operator.assignment.augmented'
197+
'"<<="': 'keyword.operator.assignment.augmented'
198+
'"%="': 'keyword.operator.assignment.augmented'
199+
'"&="': 'keyword.operator.assignment.augmented'
200+
'"&&="': 'keyword.operator.assignment.augmented'
201+
'"|="': 'keyword.operator.assignment.augmented'
202+
'"||="': 'keyword.operator.assignment.augmented'
203+
'"**="': 'keyword.operator.assignment.augmented'
204+
'"^="': 'keyword.operator.assignment.augmented'
205+
206+
'"<=>"': 'keyword.operator.comparison'
207+
'"<"': 'keyword.operator.comparison'
208+
'">"': 'keyword.operator.comparison'
209+
'"<="': 'keyword.operator.comparison'
210+
'">="': 'keyword.operator.comparison'
211+
'"==="': 'keyword.operator.comparison'
212+
'"=="': 'keyword.operator.comparison'
213+
'"=~"': 'keyword.operator.comparison'
214+
'"!="': 'keyword.operator.comparison'
215+
'"!~"': 'keyword.operator.comparison'
216+
217+
'"&&"': 'keyword.operator.logical'
218+
'"!"': 'keyword.operator.logical'
219+
'"||"': 'keyword.operator.logical'
220+
'"and"': 'keyword.operator.logical'
221+
'"not"': 'keyword.operator.logical'
222+
'"or"': 'keyword.operator.logical'
223+
'"^"': 'keyword.operator.logical'
224+
225+
'"+"': 'keyword.operator.arithmetic'
226+
'"-"': 'keyword.operator.arithmetic'
227+
'"*"': 'keyword.operator.arithmetic'
228+
'"/"': 'keyword.operator.arithmetic'
229+
'"**"': 'keyword.operator.arithmetic'
230+
'"&"': 'keyword.operator.arithmetic'
231+
'"%"': 'keyword.operator.arithmetic'
232+
233+
'call > ".", call > "&."': 'punctuation.separator.method'
234+
235+
'";"': 'punctuation.separator.statement'
236+
'","': 'punctuation.separator.object'
172237

173238
'nil': 'constant.language.nil'
174239
'true': 'constant.language.true'

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL