Konafets / antlers-idea

Adds support for Antlers, the templating language of Statamic

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

  1. Install prettier and prettier-plugin-antlers (npm install -D prettier prettier-plugin-antlers)
  2. 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
            }
        }
    ]
}
  1. Set Prettier as default formatter
    3.1. Go to Settings > Languages & Frameworks > JavaScript > Prettier
    3.2. Add {**/*,*}.{js,ts,jsx,tsx,antlers.html,vue,blade.php,css} for Run for files:
    3.3. Check the On 'Reformat Code' action

Bildschirm­foto 2023-03-15 um 11 12 42

  1. Format the following code via Code > Reformat Code
<main id="content">{{ page_builder }} {{ partial src="blocks/{type}" }} {{ /page_builder }}</main>
  1. Notice that the code does not have the heavy indentation (which should be caused by "tabWidth": 16, in .prettierrc
  2. Reinsert the code above, right click and perform "Reformat with Prettier"
  3. The code should now have the heavy indentation

Hey @marcorieser,

thanks for the detailed issue description. That helps a lot!