GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||
GeezerVison is showing github.com — fix(tui): use php_only grammar for PHP syntax highlighting by SwastikTripathi · Pull Request #58675 · anomalyco/opencode Conversation
|
|
This PR doesn't fully meet our contributing guidelines and PR template. What needs to be fixed:
Please edit this PR description to address the above within 72 hours, or it will be automatically closed. If you believe this was flagged incorrectly, please let a maintainer know. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Thanks for tracking down the cause: switching to tree-sitter-php_only.wasm is the right idea. As written, though, this doesn't fix #58664 and it breaks PHP highlighting completely.
How I checked: I loaded parsers-config.ts through opentui's tree-sitter client (highlightOnce) and also rendered the issue's snippet in the TUI with the simulated model. On the base, bare PHP gets no highlights, but <?php code and PHP inside HTML do. With this PR, the client reports No parser available for filetype php for every PHP snippet, including ones that start with <?php. The nvim-treesitter php_only/highlights.scm query doesn't load with this grammar. It also uses #lua-match?, a Neovim-only predicate that the warning at the top of this file is about (it's why the Swift entry doesn't use nvim-treesitter's query). In the TUI, the issue's code block is still plain text (screenshots below).
Keeping the new php_only wasm but keeping the existing upstream query (https://github.com/tree-sitter/tree-sitter-php/raw/refs/heads/master/queries/highlights.scm) works. Bare PHP, <?php code, classes and inline <?php … ?> in HTML all highlighted correctly when I tried it. With that, the old NOTE comment and the two new comment lines can go, so the change stays a one-line wasm swap.
Public API: unchanged.
Related: #58664
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| // NOTE: This nvim-treesitter query is currently broken, because the parser is not compatible with the query apparently. | ||
| // "https://raw.githubusercontent.com/nvim-treesitter/nvim-treesitter/refs/heads/master/queries/php/highlights.scm", | ||
| "https://github.com/tree-sitter/tree-sitter-php/raw/refs/heads/master/queries/highlights.scm", | ||
| "https://raw.githubusercontent.com/nvim-treesitter/nvim-treesitter/refs/heads/master/queries/php_only/highlights.scm", |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This query doesn't load with the php_only grammar: opentui reports No parser available for filetype php, so every PHP block (even ones starting with <?php) loses highlighting. Keeping the previous upstream query https://github.com/tree-sitter/tree-sitter-php/raw/refs/heads/master/queries/highlights.scm with the new php_only wasm works. With it, bare PHP, <?php code and inline PHP in HTML all highlighted in my test.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Sharing measurements from my (closed-as-duplicate) #58712, as the bot suggested — including one finding that looks like it matters for this PR. I drove
So the wasm switch in this PR is exactly right — the existing tree-sitter-php highlights query is already fully compatible with the php_only parser (it references no But the query swap looks like a regression: with nvim's |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Dopetaiga's measurements on anomalyco#58675 showed that nvim-treesitter's php_only/highlights.scm causes the parser to fail to register at all ("No parser available for filetype php", 0 highlights). The existing tree-sitter-php highlights.scm is fully compatible with the php_only grammar and yields correct results (7 highlights for <?php blocks, 16 for bare PHP blocks). Keep only the wasm switch. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
|
Thanks for the measurements, Dopetaiga. Your data is conclusive: the wasm switch is correct and the query swap is the regression. I reproduced the same finding: nvim-treesitter's Fixed in |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
The new commit fixes my earlier point. With the php_only grammar and the upstream tree-sitter-php query, code blocks without <?php now highlight in the TUI. Code with <?php, and inline PHP inside HTML, still highlight as before. I checked with opentui's highlightOnce and by rendering the issue's snippet with the simulated model (screenshots below). test/util/filetype.test.ts passes.
Public API: unchanged.
One small thing: the two new comment lines above wasm aren't needed for the fix and can be dropped, so the change stays a one-line swap.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
There was an error while loading. Please reload this page.
|
Dropped the two comment lines, the change is now a one-line wasm swap plus the query URL update. Thanks for the detailed review! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
The two extra comment lines are gone, so this is now a minimal one-line grammar swap. The earlier query problem was fixed in the previous commit.
I ran the issue's reproduction (a tag-less ```php block and a <?php block in one reply, simulated model). On the base only the <?php block is highlighted. With this PR both blocks are highlighted the same way (screenshots below). test/util/filetype.test.ts passes.
Public API: unchanged.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
This pull request has been automatically closed because it was not updated to meet our contributing guidelines within the 72-hour window. Feel free to open a new pull request that follows our guidelines. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
tui: PHP code blocks without<?php are not syntax highlighted
There was an error while loading. Please reload this page.