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

CSS syntax highlighting applied across whole file if no <style> tag is present #1

Closed
Sorixelle opened this issue Jun 14, 2023 · 0 comments

Comments

@Sorixelle
Copy link
Owner

Currently, if there's no <style> tags in the file, astro-mode attempts to syntax highlight everything outside the frontmatter as if it were CSS.

I've done some digging and I think this is an Emacs bug (unless I'm misunderstanding how I'm supposed to use treesit-range-settings). Will need to come up with a workaround.

Technical explanation When there's no style_element nodes in the document, treesit-parser-included-ranges returns nil for the CSS range, which makes sense. However, treesit-parser-root-node doesn't seem to return the correct node in this case. I'd expect that it would just return nil, since if there's a nil range (ie. no CSS content in the document), there shouldn't be a root node, but it instead returns a stylesheet node spanning the full range of the document, which doesn't seem correct. Because treesit's font locking applies to the whole root node, it ends up applying CSS highlighting to the whole document.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant