Formatter overrules Prettier
marcorieser opened this issue · comments
Issue
I'm using John Kosters Antlers Prettier formatter (https://github.com/Stillat/vscode-antlers-language-server/tree/main/formatcli/prettier-plugin-antlers) instead of the one provided by the plugin. In PhpStorm it's possible to define Prettier as formatter on Reformat Code
action which uses Prettier instead of the PhpStorm formatter. The issue is that the bundled formatter in the Antlers IDEA seems not to respect that checkbox. The issue is gone when disabling the plugin.
It would be nice if the plugin would respect that setting or the formatting capabilities could be deactivated via settings.
Reproduction
- Install prettier and prettier-plugin-antlers (
npm install -D prettier prettier-plugin-antlers
) - Create a
.prettierrc
file in the project root
{
"singleQuote": true,
"trailingComma": "all",
"printWidth": 140,
"tabWidth": 16,
"endOfLine": "lf",
"plugins": [
"./node_modules/prettier-plugin-antlers/"
],
"overrides": [
{
"files": "*.antlers.html",
"options": {
"parser": "antlers",
"singleQuote": false
}
}
]
}
- Set Prettier as default formatter
3.1. Go toSettings > Languages & Frameworks > JavaScript > Prettier
3.2. Add{**/*,*}.{js,ts,jsx,tsx,antlers.html,vue,blade.php,css}
forRun for files:
3.3. Check theOn 'Reformat Code' action
- Format the following code via
Code > Reformat Code
<main id="content">{{ page_builder }} {{ partial src="blocks/{type}" }} {{ /page_builder }}</main>
- Notice that the code does not have the heavy indentation (which should be caused by
"tabWidth": 16,
in.prettierrc
- Reinsert the code above, right click and perform "Reformat with Prettier"
- The code should now have the heavy indentation
Hey @marcorieser,
thanks for the detailed issue description. That helps a lot!