pedro-w / vscode-tmlanguage

Syntax highlighting for TextMate/SublimeText language definitions
MIT License
18 stars 4 forks source link

Formatting with JSON default formatter is not available #19

Open m-schwob opened 5 months ago

m-schwob commented 5 months ago

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? 
pedro-w commented 5 months ago

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!

RedCMD commented 4 months ago

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

pedro-w commented 4 months ago

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

pedro-w commented 1 week ago

@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:

Thanks!

RedCMD commented 1 week ago

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
}