I'm using Prettier for a Java project. Prettier doesn't format Java by default, so instead I installed this plugin here: https://github.com/jhipster/prettier-java
Following the directions in the README works fine, however, I'd prefer not to type a terminal command to reformat all my java files every time I modify anything. Instead I'd like to format a file anytime I save it. This is currently in my settings.json
:
"[java]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"editor.formatOnSave": true
However, using Shift+Alt+F
, the default command for formatting in VScode, results in the error "There is no formatter for "java" files installed". How do I configure my .prettierrc
file to properly use the plugin to format java files?
This is my .prettierrc file right now:
{
"plugins": [
"prettier-plugin-java"
],
"pluginSearchDirs": [
"./node_modules"
],
"overrides": [{
"files": "**/*.java",
"options": {
plugins: [
"prettier-plugin-java"
]
}
}]
}