Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Formatting with JSON default formatter is not available #19

Open
m-schwob opened this issue Feb 4, 2024 · 5 comments
Open

Formatting with JSON default formatter is not available #19

m-schwob opened this issue Feb 4, 2024 · 5 comments

Comments

@m-schwob
Copy link

m-schwob commented Feb 4, 2024

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
Copy link
Owner

pedro-w commented Feb 4, 2024

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
Copy link

RedCMD commented Feb 18, 2024

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)
microsoft/vscode#198583

@pedro-w
Copy link
Owner

pedro-w commented Feb 18, 2024

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

@pedro-w
Copy link
Owner

pedro-w commented Jun 22, 2024

@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, microsoft/vscode#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!

@RedCMD
Copy link

RedCMD commented Jun 22, 2024

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
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants