How can I select a specific formatter for VSCode even if it is not registered for that type?

Viewed 111

I'd like to tell VSCode to use a specific formatter to format a file type, when an exension is providing support for that file type but doesn't specify a formatter itself.

Specifically I've got some jinja2 files and have installed the Better Jinja extension. My .html.j2 files are recognised by the extension but I want to format them as if they were HTML.

I tried adding

"[jinja-html]": {"editor.defaultFormatter": "vscode.html-language-features"},

to my settings.json but still when I try to format, I get "There is no formatter for 'jinja-html' files installed."

As a workaround I can temporarily change the recognised file type to HTML using the "Select Language Mode" element on the bottom row, format and change back, but I hope there's an easier way.

Alternatively, is it easy to get the extension to register the correct formatter, if so I could try and put in a PR to Better Jinja?

(using VSCode 1.50.1)

0 Answers
Related