edheltzel / better-nunjucks-for-visual-studio-code

🦾 Better Nunjucks for Visual Studio Code with Snippets
https://marketplace.visualstudio.com/items?itemName=ginfuru.better-nunjucks
MIT License
22 stars 1 forks source link

Syntax highlight on other languages #7

Closed danieledep closed 1 year ago

danieledep commented 1 year ago

Hello, i really like this plugin for nunjacks, however i discovered that it breaks the syntax highlighting in similar languages, for example in .liquid files, which i handle with the official shopify extension, it doesn't let {% comment %} appear greyed out like they should. It also breaks {% schema %} tags highlighting. I tried to set the correct files associations in settings.json but it didn't help either. If i disable the extension, the liquid syntax highlight go back to work normally.

edheltzel commented 1 year ago

Hi @danieledep - do you have any code examples for me to try out?

The way the grammar is injected might be causing a conflict, with Liquid or vice-versa. I'm not sure if your use case calls for both template languages to be used, but I generally just activate Better Nunjucks on a per-workspace basis, I assume that is the case... if you're trying to use Better Nunjucks for .liquid files then, yeah it would break.

I do know that Eleventy supports the use of multiple templating languages at the same time with their render plugin which could be justification to include other grammars inside of Better Nunjucks, but I am on the fence with that for this extension. It would probably be best to create a new extension.

danieledep commented 1 year ago

Sorry i didn't make it clear that i use .liquid files for work where the only templating language is liquid and use the Shopify plugin for those.

In the meantime i wanted to use Nunjacks for personal projects where the only templating language is going to be Nunjacks and i preferred the way Better Nunjacks highlighted. So i have no projects which uses both.

That said after installing Better Nunjacks i noticed some liquid highlighting would break in liquid files: Screenshot 2023-01-06 at 12 01 26 and it went back working normally after disabling Better Nunjacks.

Of course enable and disable Better Nunjacks on a workspace basis could be a solution but i don't usually do that, for now i'm using other extensions for nunjacks files that don't mess with liquid files

edheltzel commented 1 year ago

I'm not 100% sure how the Liquid extension in VSCode works, but it's probably similar to how it injects into the default HTML grammar. I'll have to take a look at it more in-depth to be sure.

So as of right now, the best workaround is to enable based on workspace.