I've got an error when trying to format my code in Visual Studio. I have the following plugins installed for the languages I use:
shell-format (bash)
Go (golang)
PyFormat (python)
I have also set up a keybinding SHIFT+ALT+F to format a file, with the when condition:
editorHasDocumentFormattingProvider && editorTextFocus && !editorReadonly
But whenever I use this shortcut (or use auto-format on save), nothing is formatted and I see this error in the toolbar at the bottom:
"Extension 'JSON Language Features' cannot format [filepath]"
I don't know what this extension even is, since I don't have any JSON-based extentions installed.
Has anyone else seen something similar?
I just had this with Python, and it turned out the issue was that I had a line in my settings like this:
"editor.defaultFormatter": "vscode.json-language-features",
Since I wanted Python to use black
. and it's that that wasn't working and giving me the same error message you're getting, I changed the line above so it was only relevant for json
, and double checked formatters for other languages (don't forget to check settings for user, remote and workspace).
In the end, my settings for default formatting looked like this:
"editor.formatOnSave": true,
"[python]": {
"editor.codeActionsOnSave": {
"source.organizeImports.python": true,
}
},
"[django-html]": {
"editor.formatOnSave": false,
},
"[vue]": {
"editor.defaultFormatter": "octref.vetur"
},
"[json]": {
"editor.defaultFormatter": "vscode.json-language-features",
},
And presto, my Python format on save was working again.
I suspect your problem is the same, but post your settings.json
if making that vscode.json-language-features
json
specific doesn't work ...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With