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

Faulty highlighting of inline comments #66

Closed
jghauser opened this issue Oct 18, 2022 · 4 comments
Closed

Faulty highlighting of inline comments #66

jghauser opened this issue Oct 18, 2022 · 4 comments
Labels
bug Something isn't working

Comments

@jghauser
Copy link

Describe the bug

Code example

# A heading
A text with<!-- an inline comment -->

Expected behavior
The comment is highlighted as a comment.

Actual behavior
The comment is highlighted as normal text. See this screenshot (with neovim):
20221018_17h14m44s_grim

This seems similar but not quite the same as #36, though I didn't quite understand what the issue is there (and it's also marked as "invalid").

Highlighting gets applied correctly when I remove the heading and also if there's a comment as the first element of the paragraph.

@jghauser jghauser added the bug Something isn't working label Oct 18, 2022
@MDeiml
Copy link
Collaborator

MDeiml commented Oct 26, 2022

This is a very weird bug. Looking at this with nvim-treesitter-playground I can see that this is properly recognized as an (html_tag). As such the html parser should be injected which in turn should recognize the comment. It seem though that the html parser is never injected.

So to me it seems to be a bug in neovim or nvim-treesitter though I cannot say that with certainty.

A workaround that I could implement in my grammar, is to add a new node type, let's say (html_comment) which could be configured in neovim to be highlighted as a comment. In this case the html parser is not needed and everything should work fine.

@MDeiml
Copy link
Collaborator

MDeiml commented Oct 26, 2022

Just fixed a similar problem for the helix editor in helix-editor/helix#4478, but I think neovim has a different problem with this.

@jghauser
Copy link
Author

Thanks for the feedback! I can open an issue in nvim-treesitter to see what they think.

@MDeiml
Copy link
Collaborator

MDeiml commented Feb 2, 2023

Gonna close this, as it seems to be better fixed on the editor and not the parser level, but feel free to reopen if there's still any issue.

@MDeiml MDeiml closed this as completed Feb 2, 2023
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

No branches or pull requests

2 participants