Prettier-vscode: There is no formatter for 'yaml' files installed

Created on 1 Dec 2019  ·  12Comments  ·  Source: prettier/prettier-vscode

This happens regularly, every time VSCode Insiders updates itself. And every time the fix that works is different..

Global config (I have nothing relevant in the worspace config)

"[yaml]": {
  "editor.formatOnSave": true,
  "editor.defaultFormatter": "esbenp.prettier-vscode",
},
"editor.formatOnSave": true

Output tab when i click on 'Prettier' in the status bar

["INFO" - 21:15:05] Loaded module '[email protected]' from '/Users/.../node_modules/prettier/index.js'
["INFO" - 21:15:05] Enabling prettier in workspace 'xxx' for languages:
[
  "javascript",
  "mongo",
  "javascriptreact",
  "typescript",
  "typescriptreact",
  "json",
  "jsonc",
  "json5",
  "css",
  "postcss",
  "less",
  "scss",
  "graphql",
  "markdown",
  "mdx",
  "html",
  "vue",
  "yaml"
]
["INFO" - 21:15:05] Enabling prettier for range supported languages
[
  "javascript",
  "javascriptreact",
  "typescript",
  "typescriptreact",
  "json",
  "graphql"
]

If I run prettier manually, it formats my file ok, so the issue is purely within VSC

npx prettier --write '/Users/.../some/yaml/file.yml

Anything else I could try? Thanks in advance

locked

Most helpful comment

I'm having similar issues in a workspace-based environment.

Seems like the problem was introduced here - https://github.com/prettier/prettier-vscode/commit/94e73dc7a5c3ef2d349ebed4305edd59ccdd6805. Reverting the extension to 3.9.0 fixes the problem.

Seems like there's something about the pattern being added to DocumentFilter (effectively only for the non-range languages) that's causing the formatters not to be registered. Removing the pattern attribute appears to get things working again, but I'm not sure if this ends up breaking the originally intended purpose.

All 12 comments

If you are using the latest version of the plugin, you may try replacing esbenp.prettier-vscode with prettier.prettier-vscode. Not sure this advice is valid though 😄

@kachkaev they are actually identical plugins. Either name works. I’m going to merge them soon.

Does it not even run prettier when you save? The log doesn’t even show the formatter being invoked. Could you try to run “format document” and provide the log.

I'm having similar issues in a workspace-based environment.

Seems like the problem was introduced here - https://github.com/prettier/prettier-vscode/commit/94e73dc7a5c3ef2d349ebed4305edd59ccdd6805. Reverting the extension to 3.9.0 fixes the problem.

Seems like there's something about the pattern being added to DocumentFilter (effectively only for the non-range languages) that's causing the formatters not to be registered. Removing the pattern attribute appears to get things working again, but I'm not sure if this ends up breaking the originally intended purpose.

@ntotten that _was_ the log... it shows the toaster message thing "There is no formatter for 'yaml' files installed" and then does nothing. Neither when formatting manually nor when saving.

I am having the same issue for scss files. I am using VS Code on Remote; WSL: Ubuntu-18.04.

From 3.10.0 onward, VS Code gives the dialog message that "There is no formatter for 'scss' files installed."
It works on reverting to 3.9.0

Output for 3.10.0:

["INFO" - 9:07:31 AM] Extension Name: "prettier-vscode".
["INFO" - 9:07:31 AM] Extension Version: "3.10.0".
["INFO" - 9:07:31 AM] Loaded module '[email protected]' from '/mnt/e/.../node_modules/prettier/index.js'
["INFO" - 9:07:31 AM] Loaded module '[email protected]' from '/mnt/e/.../node_modules/prettier/index.js'
["INFO" - 9:07:31 AM] Enabling prettier in workspace 'yyy' for languages:
[
  "javascript",
  "mongo",
  "javascriptreact",
  "typescript",
  "typescriptreact",
  "json",
  "jsonc",
  "json5",
  "css",
  "postcss",
  "less",
  "scss",
  "graphql",
  "markdown",
  "mdx",
  "html",
  "vue",
  "yaml"
]
["INFO" - 9:07:31 AM] Enabling prettier for range supported languages
[
  "javascript",
  "javascriptreact",
  "typescript",
  "typescriptreact",
  "json",
  "graphql"
]
["INFO" - 9:07:36 AM] Loaded module '[email protected]' from '/mnt/e/dev/.../node_modules/prettier/index.js'

Output for 3.9.0:

[INFO - 9:03:42 AM] Extension Name: "prettier-vscode".
[INFO - 9:03:42 AM] Extension Version: "3.9.0".
[INFO - 9:03:42 AM] Loaded module '[email protected]' from '/mnt/e/.../node_modules/prettier/index.js'.
[INFO - 9:03:42 AM] Loaded module '[email protected]' from '/mnt/e/.../node_modules/prettier/index.js'.
[INFO - 9:03:42 AM] Enabling prettier for languages:
[
  "javascript",
  "mongo",
  "javascriptreact",
  "typescript",
  "typescriptreact",
  "json",
  "jsonc",
  "json5",
  "css",
  "postcss",
  "less",
  "scss",
  "graphql",
  "markdown",
  "mdx",
  "html",
  "vue",
  "yaml"
]
[INFO - 9:03:42 AM] Enabling prettier for range supported languages:
[
  "javascript",
  "javascriptreact",
  "typescript",
  "typescriptreact",
  "json",
  "graphql"
]
[INFO - 9:03:46 AM] Formatting /mnt/e/.../src/.../xxx.scss.
[INFO - 9:03:46 AM] Loaded module '[email protected]' from '/mnt/e/dev/.../node_modules/prettier/index.js'.
[INFO - 9:03:46 AM] Resolved ignore file to /mnt/e/.../.prettierignore.
[INFO - 9:03:46 AM] File Info:
{
  "ignored": false,
  "inferredParser": "scss"
}
[INFO - 9:03:46 AM] Prettier Options:
{
  "filepath": "/mnt/e/.../src/.../xxx.scss",
  "parser": "scss",
  "printWidth": 100,
  "trailingComma": "none",
  "tabWidth": 2,
  "semi": true,
  "singleQuote": true
}
[INFO - 9:03:46 AM] Formatting completed in 120.2919ms.

There is no formatter for 'markdown'-files installed. when trying to format markdown... it worked very recently, so must be a recent extension update.

// settings.json

  "[javascript]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  "[typescript]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  "[typescriptreact]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  "[json]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  "[html]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  "[jsonc]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  "[markdown]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
["INFO" - 14:04:16] Extension Name: "prettier-vscode".
["INFO" - 14:04:16] Extension Version: "3.11.0".
["INFO" - 14:04:16] Enabling prettier in workspace 'testdeno' for languages:
[
  "javascript",
  "mongo",
  "javascriptreact",
  "typescript",
  "typescriptreact",
  "json",
  "jsonc",
  "json5",
  "css",
  "postcss",
  "less",
  "scss",
  "graphql",
  "markdown",
  "mdx",
  "html",
  "vue",
  "yaml"
]
["INFO" - 14:04:16] Enabling prettier for range supported languages
[
  "javascript",
  "javascriptreact",
  "typescript",
  "typescriptreact",
  "json",
  "graphql"
]

@ntotten Same problem's here, 4 steps to reproduce this issue:

  1. Open a fresh VS Code window
  2. Open one folder, and we will find some logs like Enabling prettier in workspace 'xxx' for languages:
  3. New an untitled editor and type some markdown content, then change language mode to Markdown.
  4. Format Document.

A message will prompt:

There is no formatter for 'markdown' files installed.

It seems prettier extension does not register formatter for files other than opened workspace, e.g. untitled tmp files

same here with .css and .json

This should be fixed in 3.13+. Please reopen if you still are seeing the issue.

Brilliant, can confirm it is fixed, thanks 🙇

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sebastijandumancic picture sebastijandumancic  ·  4Comments

bardware picture bardware  ·  4Comments

Tanmccuin picture Tanmccuin  ·  3Comments

PetrykowskiM picture PetrykowskiM  ·  3Comments

Connorelsea picture Connorelsea  ·  4Comments