Skip to content
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

Parser dependencies don't start automatically #561

Closed
flexagoon opened this issue Oct 16, 2024 · 6 comments · Fixed by #562
Closed

Parser dependencies don't start automatically #561

flexagoon opened this issue Oct 16, 2024 · 6 comments · Fixed by #562
Assignees
Labels
bug Something isn't working

Comments

@flexagoon
Copy link

On some parsers (I currently found astro and php to be affected) highlighting doesn't work when you open a file. It sometimes starts working after restarting treesitter or switching a file, but sometimes doesn't.

Easiest way to reproduce:

<?php

echo "Hello World!";

When you open this file with treesitter highlighting enabled, it looks like this:

image

However, after running :lua vim.treesitter.stop(); vim.treesitter.start():

image

@mrcjkb
Copy link
Member

mrcjkb commented Oct 16, 2024

hey 👋

thanks for reporting. Are you using scm parsers or 0.0.x versioned parsers? If the latter, which versions?

This is a known issue with scm parsers that depend on other parsers or queries, as you cannot ensure compatibility.
The recommendation is to use the versioned parsers.

@flexagoon
Copy link
Author

@mrcjkb I'm using versioned parsers, the php parser version is 0.0.33.

A thing I'm also experiencing sometimes (but not the other times?..) is that I need to wait a while after opening the file, and only restart treesitter after that. So if I open the file and immediately restart it, nothing happens, but if I wait 20 seconds and restart it, the highlighting gets fixed.

@flexagoon
Copy link
Author

@mrcjkb seems like this is caused by nvim-neorocks/rocks-treesitter.nvim#39, because manually installing the tree-sitter-php_only parser fixes the issue.

It seems like parsers which are installed implicitly as dependencies just don't get started automatically sometimes.

@flexagoon
Copy link
Author

I'll close that issue and copy it here:

nvim-neorocks/rocks-treesitter.nvim#20 was supposed to be fixed by adding tree-sitter-ecma to the parser's dependencies, however, if you install tree-sitter-typescript without manually installing tree-sitter-ecma, the issue described in nvim-neorocks/rocks-treesitter.nvim#20 still occurs.

@flexagoon flexagoon changed the title Highlighting doesn't get enabled on some parsers Parser dependencies don't start automatically Oct 16, 2024
@mrcjkb
Copy link
Member

mrcjkb commented Oct 16, 2024

Ah, I see where the issue is. Those dependencies are for queries, not parsers.
rocks.nvim automatically adds parsers to the runtimepath, but not queries.

I'm quite busy right now, but I'll see if I can come up with a fix on Friday.

Moving this issue to rocks.nvim.

@mrcjkb mrcjkb transferred this issue from nvim-neorocks/rocks-treesitter.nvim Oct 16, 2024
@mrcjkb mrcjkb self-assigned this Oct 16, 2024
@mrcjkb mrcjkb added the bug Something isn't working label Oct 16, 2024
@mrcjkb
Copy link
Member

mrcjkb commented Oct 17, 2024

Just tried it out. It works fine on my end with tree-sitter-typescript, but not with tree-sitter-php. For tree-sitter-php, I have to manually install tree-sitter-php_only.

Update: The issue is that there's a delay until the package gets added to the runtimepath.
If I open up nvim and wait a bit, it works for php, too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants