ronnidc / vscode-nunjucks

Nunjucks for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=ronnidc.nunjucks
65 stars 18 forks source link

How can I ignore the .html file ? #13

Closed lichenhao closed 6 years ago

lichenhao commented 7 years ago

The .html file is not .nunjucks template . How can I disabled this ? What should I do?

fgallardograzio commented 6 years ago

@lichenhao I just installed this extension and was also bothered by it taking over html files. In my opinion this is a very bad approach. Nunjucks extends the html syntax. So valid html is very likely to be valid nunjucks, not the other way around. Forcing nunjucks over html might result in broken markup.

Especially considering we're losing intellisense, emmet, etc. when working with nunj templates.

Back to your question. You can use the files.associations setting. You can add something like this to your user settings:

"files.associations": {
    "*.htm": "html",
    "*.html": "html"
}

This way, VS Code will treat all .htm and .html files as html files instead of nunjucks. You can also set this in your workspace settings, and match for specific folders, etc. using for example:

"files.associations": {
    "**/src/templ/*.html": "nunjucks"
}

So that those files are treated as nunjucks templates even though the .html extension is used. You can get creative.

More info: https://code.visualstudio.com/docs/languages/overview and https://code.visualstudio.com/docs/languages/identifiers

lichenhao commented 6 years ago

Yeah~ This works well Thanks for your help.

shiolovesgod commented 5 years ago

@fgallardograzio thanks! that was driving me crazy

knightspore commented 3 years ago

This is still a working fix - been driving me mad for months! Cheers @fgallardograzio x