Describe the bug
The dprint VS Code extension does not properly register as a formatter for the jsonc language ID. As a result, dprint does not appear in the "Default Formatter" dropdown for JSON with Comments (e.g. settings.json, launch.json, *.code-workspace) unless the user manually sets "[jsonc]": { "editor.defaultFormatter": "dprint.dprint" } in settings.
To reproduce
- Install the dprint extension and ensure a dprint config exists (e.g. with the json plugin).
- Open a
.jsonc or settings.json (or any file with language mode "JSON with Comments").
- Open the Command Palette → "Format Document With..." or check Settings → Default Formatter for
jsonc.
- dprint is not listed / not the default.
Expected
dprint should be offered as a formatter for jsonc (and json) when the workspace has dprint config that includes the json plugin.
Workaround
Add to workspace or user settings:
"[jsonc]": { "editor.defaultFormatter": "dprint.dprint" }
Cause
The extension registers DocumentFormattingEditProvider only with document selectors built from glob patterns ({ scheme: "file", pattern }). VS Code does not reliably associate such glob-only selectors with the jsonc language ID, so the extension does not appear in the formatter list for that language.
Fix
Explicitly register the same provider for language IDs jsonc and json (e.g. add { scheme: "file", language: "jsonc" } and { scheme: "file", language: "json" } to the document selectors). I can open a PR with this change.
Describe the bug
The dprint VS Code extension does not properly register as a formatter for the
jsonclanguage ID. As a result, dprint does not appear in the "Default Formatter" dropdown for JSON with Comments (e.g.settings.json,launch.json,*.code-workspace) unless the user manually sets"[jsonc]": { "editor.defaultFormatter": "dprint.dprint" }in settings.To reproduce
.jsoncorsettings.json(or any file with language mode "JSON with Comments").jsonc.Expected
dprint should be offered as a formatter for
jsonc(andjson) when the workspace has dprint config that includes the json plugin.Workaround
Add to workspace or user settings:
Cause
The extension registers
DocumentFormattingEditProvideronly with document selectors built from glob patterns ({ scheme: "file", pattern }). VS Code does not reliably associate such glob-only selectors with thejsonclanguage ID, so the extension does not appear in the formatter list for that language.Fix
Explicitly register the same provider for language IDs
jsoncandjson(e.g. add{ scheme: "file", language: "jsonc" }and{ scheme: "file", language: "json" }to the document selectors). I can open a PR with this change.