问题
I'm using the Django extension for intellisense and syntax highlighting on Jinja templates (VS Code) but cannot figure out how to use my default formatter (HookyQR Beautify) to beautify/format my django-html files. Would that be possible?
回答1:
I need to use beautify only for django-html
files, I've got prettier working for js, html, css then flake8 and autopep8 for python, for django-html
prettier wrongly formats jinja template strings,
so I disabled the django-html
from pettier languages and used these settings got from this issue discussion., works for me well.
{
"prettier.disableLanguages": ["django-html"],
"beautify.language": {
"html": [
"django-html"
]
},
"[django-html]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "HookyQR.beautify"
}
}
回答2:
This seems to have sorted it for me, allowing me to keep HookyQR Beautify for normal HTML files and have a separate one for django-html files:
"beautify.language": {
"html": [
"django-html"
]
}
来源:https://stackoverflow.com/questions/61224427/add-a-formatter-beautifier-to-django-html-files-in-visual-studio-code