Himujjal / tree-sitter-svelte

Tree sitter grammar for Svelte
MIT License
82 stars 14 forks source link

Syntax Highlighting Issues with Svelte Files in Neovim Using Tree-sitter, Possibly Related to Dot Notation #58

Open axzilla opened 7 months ago

axzilla commented 7 months ago

I am experiencing a problem with the syntax highlighting of Svelte files in Neovim when using Tree-sitter. The highlighting works correctly with smaller files but begins to fail when each or if blocks are introduced, especially in lines involving dot notation (e.g., <Card.Title>). This issue persists across different configurations, including setups with LazyVim and AstroVim, indicating it might not be specific to my personal setup. I am using the latest version of Neovim.

Environment Details:

Steps to Reproduce:

  1. Open a larger Svelte file containing each or if blocks.
  2. Observe the syntax highlighting behavior, particularly after line 82 and around lines using dot notation.

Expected Behavior:

Syntax highlighting should remain consistent throughout the file, regardless of the presence of Svelte-specific syntax, control structures, or dot notation usage.

Actual Behavior:

Syntax highlighting fails, losing coloration after specific blocks of code are introduced, particularly those involving dot notation.

Additional Notes:

Attempts to resolve the issue by switching themes (e.g., Rose-pine.nvim) or inspecting with :InspectTree have not been successful. Further investigation and community support are needed to determine if this is a bug with the Svelte parser integration or a compatibility issue with specific configurations.

104n9v6w3nwc1

https://github.com/Himujjal/tree-sitter-svelte/assets/26936893/a623f33b-5dde-4ed7-8205-92a868051bee

axzilla commented 7 months ago

I've now found out that it's really due to the HTML dot notation. I changed the imports and tags to CamelCase and everything works as expected. That's pretty bad!

lab-do commented 5 months ago

I have the same problem, it makes Neovim unusable for Svelte projects.

michenriksen commented 5 months ago

The grammar that nvim-treesitter installs is actually https://github.com/tree-sitter-grammars/tree-sitter-svelte and not this one (I also got confused because this repo is the first result when searching on Google)

I have opened a PR on tree-sitter-grammars/tree-sitter-svelte which resolves this issue: https://github.com/tree-sitter-grammars/tree-sitter-svelte/pull/4.

Hopefully, it will be merged quickly because there doesn't seem to be an easy way to override the installation source in nvim-treesitter 🤞

axzilla commented 5 months ago

The grammar that nvim-treesitter installs is actually https://github.com/tree-sitter-grammars/tree-sitter-svelte and not this one (I also got confused because this repo is the first result when searching on Google)

I have opened a PR on tree-sitter-grammars/tree-sitter-svelte which resolves this issue: tree-sitter-grammars/tree-sitter-svelte#4.

Hopefully, it will be merged quickly because there doesn't seem to be an easy way to override the installation source in nvim-treesitter 🤞

Hey, oh, good to know, thanks for letting me know. I see you already opened a related issue in the right repo. Thanks for that! Hopefully it will be fixed soon!