-
-
Notifications
You must be signed in to change notification settings - Fork 136
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
Lower-case-ing the heredoc language #554
base: master
Are you sure you want to change the base?
Changes from all commits
f34e6bb
9a2dfcf
8058b62
f9f4638
a7c0bec
ab40f77
3426327
dae1575
0db3806
f0c4793
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -90,8 +90,7 @@ | |
|
||
; "Foo" in `Foo::Bar`. | ||
(scope_resolution | ||
scope: (constant) @support.other.namespace.ruby | ||
(#set! test.final "true")) | ||
scope: (constant) @support.other.namespace.ruby) | ||
|
||
; "::" in `Foo::Bar`. | ||
(scope_resolution | ||
|
@@ -100,8 +99,7 @@ | |
|
||
; "Bar" in `Foo::Bar`. | ||
(scope_resolution | ||
name: (constant) @support.other.class.ruby | ||
(#set! test.final "true")) | ||
name: (constant) @support.other.class.ruby) | ||
|
||
|
||
|
||
|
@@ -145,6 +143,8 @@ | |
(assignment | ||
left: (identifier) @variable.other.assignment.ruby) | ||
|
||
(constant) @constant.ruby | ||
|
||
(element_reference | ||
(constant) @support.class.ruby | ||
(#match? @support.class.ruby "^(Set)$")) | ||
|
@@ -164,6 +164,7 @@ | |
(#set! test.final "true")) | ||
|
||
(call "." @keyword.operator.accessor.ruby (#set! test.final "true")) | ||
(call "&." @keyword.operator.accessor.ruby (#set! test.final "true")) | ||
|
||
((identifier) @constant.builtin.ruby | ||
(#match? @constant.builtin.ruby "^__(FILE|LINE|ENCODING)__$")) | ||
|
@@ -202,7 +203,10 @@ | |
(#set! test.final true)) | ||
|
||
(pair | ||
key: (hash_key_symbol) | ||
key: (simple_symbol) @constant.other.symbol.hashkey.ruby) | ||
|
||
(pair | ||
key: (hash_key_symbol) @constant.other.symbol.hashkey.ruby | ||
; In `{ foo: 'bar' }` syntax, the `:` both marks the key as a symbol and | ||
; separates it from its value. | ||
":" @punctuation.definition.constant.hashkey.ruby | ||
|
@@ -263,16 +267,6 @@ | |
(string_content)? | ||
"\"" @punctuation.definition.string.end.ruby) | ||
@string.quoted.other.interpolated.ruby | ||
(#match? @string.quoted.other.interpolated.ruby "^%Q") | ||
(#set! test.final true)) | ||
|
||
|
||
( | ||
(string | ||
"\"" @punctuation.definition.string.begin.ruby | ||
(string_content)? | ||
"\"" @punctuation.definition.string.end.ruby) | ||
@string.quoted.other.ruby | ||
Comment on lines
-266
to
-275
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Was this section not needed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There were some misbehaviors on the string matching - some interpolated strings were being detected as non-interpolated, and vice-versa. When I fixed these, I extracted most of the changes into specific matches. In this specific case, I did not remove the match of double-quoted strings - I just removed the restriction on the previous rule (https://github.com/pulsar-edit/pulsar/pull/554/files#diff-82574a2099439cbee59d5f974dbe593145214402078d948cf9f49378d9637e40R264-L266) and that basically became the exact same match that we have here :D |
||
(#set! test.final true)) | ||
|
||
; Highlight the interpolation inside of a string. | ||
|
@@ -446,7 +440,7 @@ | |
(#set! test.final true)) | ||
|
||
(singleton_class | ||
"<<" @keyword.operator.assigment.ruby) | ||
"<<" @keyword.operator.assignment.ruby) | ||
|
||
(binary | ||
"|" @keyword.operator.bitwise.ruby) | ||
|
@@ -469,7 +463,7 @@ | |
"+=" | ||
"-=" | ||
"<<" | ||
] @keyword.operator.assigment.ruby | ||
] @keyword.operator.assignment.ruby | ||
|
||
[ | ||
"||" | ||
|
@@ -496,6 +490,13 @@ | |
; PUNCTUATION | ||
; =========== | ||
|
||
(symbol_array | ||
"%i(" @punctuation.definition.begin.array.other.ruby | ||
")" @punctuation.definition.end.array.other.ruby) | ||
(string_array | ||
"%w(" @punctuation.definition.begin.array.other.ruby | ||
")" @punctuation.definition.end.array.other.ruby) | ||
|
||
"[" @punctuation.definition.begin.array.bracket.square.ruby | ||
"]" @punctuation.definition.end.array.bracket.square.ruby | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason I had for doing
test.final
here — and it's more of a feeling than anything — is that I felt we didn't really gain anything from tagging one range as bothsupport.other.class.ruby
andconstant.ruby
.There are places where it makes sense to do stuff like that, but if we apply both scopes, we end up leaving it to the syntax theme to decide which styles win out, and often that's not an intentional decision by the theme author as much as it's just an accident of CSS specificity and ordering of selectors. It also brings ordering in the SCM file into play — since
constant.ruby
is declared later in the file, that scope name will be in the innerspan
, and that also has an effect on which styles win out.Technically, lots of things are marked as
constant
intree-sitter-ruby
, just as lots of things are marked asidentifier
, and I'm not certain that we give the user much useful information by scoping each one asconstant
even when it serves a more specific function.I've tended to assign a
constant
scope only for (a) number literals, (b) built-in language constants like booleans andnull
, and (c) declarations thatLOOK_LIKE_CONSTANTS
and don't serve other functions. Lots of TM-style themes go even more conservative than that — usingconstant
for A and B but using thevariable
scope for C.I'm not arguing that any of this is necessarily wrong, and I'm happy to see how it shakes out, but that was the thinking behind the original decision.