Skip to content

Commit d009fe4

Browse files
committed
Highlight instance vars, method defs, and keyword params distinctly
These three constructs are folded into broader shared captures, so themes cannot color them independently: - instance variables share `@variable.special` with `self`, `super`, and class variables - method definitions share `@function.method` with method calls - keyword parameters share `@variable.parameter` with positional parameters Give each its own dotted sub-scope, following the sub-scoping convention already used throughout this file (e.g. `function.method.builtin`, `keyword.control.conditional`, `string.special.symbol`): - (instance_variable) -> @variable.special.instance - method / singleton_method -> @function.method.definition - keyword_parameter -> @variable.parameter.keyword Fully backwards-compatible: Zed resolves highlight names by longest prefix, so themes that only define `variable.special`, `function.method`, or `variable.parameter` render these exactly as before. Themes can now opt in to distinguishing them.
1 parent 67c79df commit d009fe4

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

languages/ruby/highlights.scm

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,13 @@
8181
name: [
8282
(identifier)
8383
(constant)
84-
] @function.method)
84+
] @function.method.definition)
8585

8686
(singleton_method
8787
name: [
8888
(identifier)
8989
(constant)
90-
] @function.method)
90+
] @function.method.definition)
9191

9292
(method_parameters
9393
[
@@ -98,7 +98,7 @@
9898
[
9999
name: (identifier)
100100
":"
101-
] @variable.parameter)
101+
] @variable.parameter.keyword)
102102
])
103103

104104
(block_parameters
@@ -138,10 +138,9 @@
138138

139139
(super) @variable.special
140140

141-
[
142-
(class_variable)
143-
(instance_variable)
144-
] @variable.special
141+
(class_variable) @variable.special
142+
143+
(instance_variable) @variable.special.instance
145144

146145
((call
147146
!receiver

0 commit comments

Comments
 (0)