Commit Graph

42160 Commits

Author SHA1 Message Date
Andrew Dupont
e0015218b7 A vain attempt to get the integration testing working for PHP 2024-01-21 16:11:34 -08:00
Andrew Dupont
6b89902761 [language-php] Update parserSource field for internal PHP grammar 2024-01-21 13:32:01 -08:00
Andrew Dupont
2aa0cea8a4 [language-gfm] Actually change the scope name for a horizontal rule…
…instead of forgetting to add the file.
2024-01-21 13:22:36 -08:00
Andrew Dupont
ee220dd6ef [language-gfm] Change scope for a horizontal rule…
to `markup.horizontal-rule.gfm` and add styles to all eight built-in syntax themes to account for it.

All the old GFM scopes are just named however they needed to be named in order to produce syntax highlighting to the grammar author, semantics be damned. Instead, we're making sure the semantics are correct, then adapting the syntax themes accordingly.
2024-01-21 13:20:56 -08:00
Andrew Dupont
4c0e7dda9f Highlight JSON keys in the other six builtin syntax themes…
…always using the color that was already used to highlight YAML keys.
2024-01-21 13:07:16 -08:00
Andrew Dupont
e0009ce188 Highlight JSON keys in one-(dark|light)-ui
Upon suggestion, `@hue-5` was chosen for consistency because the same color is used for keys in YAML.
2024-01-21 12:56:34 -08:00
Andrew Dupont
1e7e1351d8 [language-javascript] Ensure object properties are scoped as entity
…instead of `variable` when a function is on the right-hand side of an assignment.
2024-01-21 12:53:44 -08:00
Andrew Dupont
8525a3f622 [language-php] Move value type usages into support.storage.type 2024-01-21 12:51:47 -08:00
Andrew Dupont
cc2785b59f Log context when a parser fails to load
Previously this just put a bunch of `web-tree-sitter` errors in the console without telling you which thing failed. This is a marginal improvement.
2024-01-21 11:22:30 -08:00
Andrew Dupont
8766102edc Clip injection ranges to the bounds of the buffer when needed 2024-01-21 11:20:43 -08:00
Andrew Dupont
33f193cd60 [language-php] Update tree-sitter-php to latest 2024-01-21 11:16:51 -08:00
Andrew Dupont
aeeb03a824 Adopt the support.storage compromise found in legacy Tree-sitter…
…in which all _value types_ are scoped under `support.storage`. The goal is to avoid drawing an arbitrary distinction between, say, `int` and `SomeCustomCType` — those things are different, but not _so_ different that they belong in separate root scope namespaces.

`storage.type` can be used for core language constructs — `var`, `class`, `function`, `struct`, `enum`, `namespace`, and so on. `support.storage.type` should be used for any _recognized_ value type — certainly core language types like `int`, but also other things if they make sense. `support.other.storage.type` can be used for user-defined types, or any other types that we don't recognize. (Using the `support.other` ordering here adheres to our new convention of reserving all of `support.other` for user-defined things.)

The point of this compromise is that both the `syntax--storage` and `syntax--support` class names are present so that many themes will still highlight these tokens as though they were in the root `storage` namespace.

This commit changes the C/C++ and TypeScript `highlights.scm` files. The results appear to be satisfactory to my eye after testing on two of the builtin themes.

I’ve updated the taxonomy document to reflect this new proposal:
https://gist.github.com/savetheclocktower/c9607b97477d4817911e4f2f8db89679#file-scope-taxonomy-md
2024-01-21 10:33:01 -08:00
Andrew Dupont
e48ac62ea5 Correct the PHP delimiters in the integration test 2024-01-20 21:27:08 -08:00
Andrew Dupont
46877b05ff [language-php] Add meta.embedded.block/meta.embedded.line
…to each PHP section in order to match the functionality of the TextMate grammar.

This was a gigantic endeavor and involved doing several things that were on my “ugh, I’ll get around to it” list:

* To make some of this stuff work, we were using two different PHP parser layers. The root one did the syntax highlighting and separated the HTML from the rest, and the deeper injection was there just so we could scope some ranges as `source.php`.

  That doesn’t work because of rules we have about shallower layers acting before deeper layers when iterating through syntax highlighting boundaries. I was trying to be too clever. Now the _root_ layer is the one that does no highlighting, and the _deeper_ layer is the one that exists to apply `source.php` _and then_ perform highlighting and indentation hinting and folding and whatnot.

  If we need to, we can move some of the queries to the root layer for whatever reason; maybe we come across a bug six months from now that could be fixed if we made the root layer in charge of folding. We have options.

* All boundaries for `HighlightIterator`s now _either_ open one or more scopes _or_ close one or more scopes. If one boundary can close some scopes and open others, then boundaries on different layers that share a buffer position cannot possibly close/open in the correct order because they can't intermingle. This needed to happen and this was as good of an excuse as any to do it.
* We needed to present sane PHP opening/closing ranges to the injection. Ironically, `tree-sitter-php` itself makes this nearly impossible because of how the tree is structured; it tries to hide the `<?php` and `?>` tags from the PHP layer and treat them as text, despite the fact that PHP is the thing that knows how to parse that.

  The best way to do this — at least until I encounter a reason why it can’t work — is to find all the `<?php`s and `?>`s, sort them, group them, and build fake node ranges. This is fine! I mean, it’s ridiculous, but it’s fine! The ranges that we hand off to another parser are allowed to be completely arbitrary!

  This lets us do what we were only approximating before: have _one_ PHP injection layer with _any number of_ content ranges, each of which begins with `<?php` and ends with `?>` without trying to claim any surrounding whitespace. This would be worth it even if we didn’t have to do any of this other stuff.

* Each content range of the injection needs _either_ `meta.embedded.line.php` _or_ `meta.embedded.block.php` depending on whether the range begins and ends on the same line. This is not something I was willing to regress on because it's _hard_ to distinguish between PHP and non-PHP unless your editor helps you out, and because I wasn't going to go into a bunch of themes and tell them to treat `source.php` like `meta.embedded`.

  This also meant that we needed to be able to add _multiple_ “root” scope names per content range. But we already had a mode in which the `languageScope` injection option could be a callback, so it wasn't hard to make it a callback that could take extra parameters for the buffer and range.

  This isn't a feature that I'm eager for other grammars to use, or even necessarily know about, but it was what we needed to deliver feature parity here. And none of it would have been necessary if `tree-sitter-php` made more sensible choices. (Whatever. Maybe what I want isn't possible for some strange reason.)

All existing tests pass. Tests have been written for the new `languageScope` features. Tests need to be written for PHP just like for all other language grammars, but that was on the to-do list anyway. If any of this turns out to be catastrophic, it’s easy to roll back, but tests are passing on my machine and I expect them to pass in CI.
2024-01-20 20:49:17 -08:00
Andrew Dupont
2a0ebacf62 An injection with no highlights query should still apply its root scope 2024-01-20 13:50:31 -08:00
Andrew Dupont
4d8a7219c3 [language-c] Highlight struct designated initializers 2024-01-20 12:07:22 -08:00
Andrew Dupont
c2fb3075df [language-php] Small fixes…
* Properly highlight comments like `/***/`
* Add `intdiv` as a builtin function
* Change PHPDoc tags back to a `keyword` scope rather than an `entity.name.tag` scope
* Highlight more PHPDoc types
2024-01-20 10:34:48 -08:00
Andrew Dupont
7130f77f27 [language-typescript] Highlight the wildcard import symbol 2024-01-19 23:25:23 -08:00
Andrew Dupont
65de46faa1 [language-html] Update tree-sitter-embedded-template to latest…
…which will make EJS and ERB much more pleasant to use, and which I should've done ages ago.

Most notably: empty tags like `<% %>` are now valid, so the highlighting won't go nuts before you've typed anything.
2024-01-19 23:16:15 -08:00
Andrew Dupont
88ffe7838b Fix issue where suggestedIndentForBufferRow uses the wrong tree…
…because it makes a different judgment about which layer should own the indent decision than `suggestedIndentForBufferRows`, plural, did.
2024-01-19 22:17:30 -08:00
Andrew Dupont
e1e12ff5ba [language-gfm] Test for undetected URLs in paragraphs…
…and inject `hyperlink` into them for auto-linking.
2024-01-19 21:25:00 -08:00
Andrew Dupont
054b067ff2 Update highlights for all regex injections…
…and add a distinct copy for TypeScript so that it works even if `language-javascript` is disabled or replaced.

(We might want to just make `language-regex` and have it export a service.)
2024-01-19 21:01:07 -08:00
Andrew Dupont
81ca97e0c7 [language-ruby] Tweak scope name for regex injections 2024-01-19 20:47:00 -08:00
Andrew Dupont
c01099323f (forgot to change this spec) 2024-01-19 20:45:48 -08:00
Andrew Dupont
cf884f5f86 Update tree-sitter-regex for both JavaScript and Ruby 2024-01-19 20:45:33 -08:00
Andrew Dupont
fd0b9a2dd7 [language-ruby] Move files around to conform better to convention 2024-01-19 20:39:07 -08:00
Andrew Dupont
38534bbd84 [language-ruby] Update tree-sitter-ruby to latest 2024-01-19 20:33:07 -08:00
Andrew Dupont
aff27bb5bf [language-html] Update tree-sitter-html to latest 2024-01-19 20:26:27 -08:00
Andrew Dupont
4a91444ded
Merge pull request #860 from claytonrcarter/wasm-tree-sitter-compat
fix(tree-sitter): pass node text to grammar
2024-01-19 20:08:35 -08:00
Andrew Dupont
e874d51362 [language-c] Update the tree-sitter-c and tree-sitter-cpp parsers 2024-01-19 20:02:22 -08:00
Andrew Dupont
5aef671f5c [language-php] Fix incorrect indentation after ternary expressions 2024-01-19 18:42:25 -08:00
Andrew Dupont
5e84a7cda4 [language-shellscript] Highlighting fixes…
* add `declare` and `readonly` modifiers
* distinguish $()-style command substitution from backtick substitution
* prevent double-scoping of punctuation
2024-01-19 17:27:44 -08:00
Andrew Dupont
dcf451cf1b [language-python] Update to latest tree-sitter-python
…and add some items to `highlights.scm` that fell through the cracks.
2024-01-19 16:43:32 -08:00
Andrew Dupont
a13ffcd694 [language-typescript] Move the “Objects” section in highlights.scm
…so that the builtins section gets prioritized higher.
2024-01-19 16:42:01 -08:00
Andrew Dupont
3cd7557504 [language-shellscript] Highlight while and add other fixes…
* `<` as a file redirect operator
* `((` and `))` as punctuation
2024-01-18 20:28:27 -08:00
Andrew Dupont
57e812b5bc [language-typescript] Harmonize syntax decisions between JS and TS…
…and add a new style to `one-dark-syntax` and `one-light-syntax` to ensure continuity of appearance now that object properties are not all treated as `variable`s.

Also, scope private field method definitions in both JS and TS.
2024-01-18 19:05:17 -08:00
Andrew Dupont
937cb15953 [language-c] Apply some fixes to C/C++ highlighting
Choosing the other side of some dilemmas I had to resolve six months ago. Highlighting between modern and legacy Tree-sitters now appears to be identical to me (with rare exception) on the One Dark theme.
2024-01-18 18:33:00 -08:00
Andrew Dupont
f171f33844 [language-go] Highlight method names like function names 2024-01-18 17:31:46 -08:00
Andrew Dupont
3864c0d0f7 [language-go] Update tree-sitter-go parser to latest…
…and include some highlighting fixes from #869.
2024-01-18 13:53:23 -08:00
Andrew Dupont
1ed84b8180 Adjust fold in response to tree-sitter-javascript change 2024-01-18 13:53:23 -08:00
Andrew Dupont
4a8df88ca5 Fix other grammar paths 2024-01-18 13:53:23 -08:00
Andrew Dupont
13c5c07412 Change references to JS grammar path in specs 2024-01-18 13:53:23 -08:00
Andrew Dupont
52e2efd0a6 Fix CI validation trying to check for a file that has been deleted 2024-01-18 13:53:23 -08:00
Andrew Dupont
cac042b3c0 [language-php] Support some things that were accidentally omitted…
…like

* Constructors (the "Foo" in `new Foo()`)
* Certain function-like builtins like `list`, `unset`, and `print`
2024-01-18 13:53:23 -08:00
Andrew Dupont
a53a9f6c15 [language-javascript] Fix indents.scm after the parser upgrade 2024-01-18 13:53:23 -08:00
Andrew Dupont
3d526d7959 Add a setting to control switch/case indentation for JS/TS
This is our first venture into _configurable_ indentation. Exciting times.
2024-01-18 13:53:23 -08:00
Andrew Dupont
55a8762478 [language-css] Update tree-sitter-css parser to latest 2024-01-18 13:53:23 -08:00
Andrew Dupont
1ddcff43bd [language-javascript] Rename grammar files for consistency 2024-01-18 13:53:23 -08:00
Andrew Dupont
79d1cff437 [language-javascript] Upgrade tree-sitter-javascript parser to latest…
…and move some files around for consistency.
2024-01-18 13:53:23 -08:00
Andrew Dupont
99388fabb8 [language-typescript] Correctly highlight the angle brackets of TSX tags 2024-01-18 13:53:23 -08:00