vscode-tmlanguage icon indicating copy to clipboard operation
vscode-tmlanguage copied to clipboard

Formatting with JSON default formatter is not available

Open m-schwob opened this issue 1 year ago • 5 comments

Since this extension does not provide a formatting service, I tried to use the default VsCode JSON formatter.

I added the following to setting.json and it still does not work:

    "editor.defaultFormatter": "vscode.json-language-features",
  },```
  
  maybe the extension blocks the formatting services? 

m-schwob avatar Feb 04 '24 11:02 m-schwob

Hi, It's not blocked deliberately. I've had this before - basically I want VSCode to do all the normal JSON things plus a little bit extra for tmlanguage (and the same for YAML), but I can't figure out how to do this. I'll have another think but I am really not a VScode expert and the way forward is not obvious to me!

pedro-w avatar Feb 04 '24 20:02 pedro-w

the built-in JSON extension only activates on the languageId; json however this extension uses json-tmlanguage

you'll be able to use the new jsonLanguageParticipants feature in the next release (currently in Insiders) https://github.com/microsoft/vscode/pull/198583

RedCMD avatar Feb 18 '24 10:02 RedCMD

@RedCMD that's good news, hopefully I will be able to get things working that way. Thanks!

pedro-w avatar Feb 18 '24 11:02 pedro-w

@RedCMD I added some jsonLanguageParticipants-related things to package.json and it seems to work, at least, I can format tmLanguage.json files in the editor.

I had a few questions but unfortunately your PR, https://github.com/microsoft/vscode/pull/198583 is now locked. If you wouldn't mind:

  • What version was this implemented for (ie. what XX should I put in my engines: {vscode: "^1.XX"}
  • Is it possible to allow comments in the json, and if so, how?

Thanks!

pedro-w avatar Jun 22 '24 19:06 pedro-w

VSCode engine 1.87.0

VSCode's JSON TextMate engine doesn't support C style comments at all however you can disable the warning message via an option in a schema

{
  "allowComments": true,
  "allowTrailingCommas": true
}

RedCMD avatar Jun 22 '24 21:06 RedCMD