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

[json] Allow extensions to enable the builtin json-language-features extension on their own personal json languageId #198025

Closed
RedCMD opened this issue Nov 12, 2023 · 6 comments · Fixed by #198583
Assignees
Labels
feature-request Request for new features or functionality insiders-released Patch has been released in VS Code Insiders json JSON support issues verification-needed Verification of issue is requested verified Verification succeeded
Milestone

Comments

@RedCMD
Copy link
Contributor

RedCMD commented Nov 12, 2023

Currently the builtin json extension supports the language ids json and jsonc
It would be nice if other extensions could add their own languageId to the list

from my testing, simply allowing the possibility to add languages to the documentSelector will work

const documentSelector = ['json', 'jsonc'];

and also modifying the "activationEvents"

"activationEvents": [
"onLanguage:json",
"onLanguage:jsonc"
],

also very closely related @jeff-hykin
the language Code Snippets does not have the json language server enabled

@aeschli
Copy link
Contributor

aeschli commented Nov 13, 2023

For html we support something called language participants:
A language can declare a set of features they want to use from html:
#156200

If that's useful, I'm happy to take a PR for JSON.

But maybe first. may I ask what kind of language that is?

@RedCMD
Copy link
Contributor Author

RedCMD commented Nov 13, 2023

But maybe first. may I ask what kind of language that is?

Syntax highlighter for VSCodes json TextMate files
https://marketplace.visualstudio.com/items?itemName=RedCMD.tmlanguage-syntax-highlighter

also the new code-snippets edition would benefit from having the json lanuage features (and JSONL)

but....
would that disable my extension's additional language features?

@aeschli
Copy link
Contributor

aeschli commented Nov 13, 2023

Ok I see. No, your proposals would be merged with the proposals from the lJSON anguage server. But you might get conflicting proposals unless you can tune the schema the way you want it.

An alternative is to not define a new language but keep it as JSON.
Use additional providers for diagnostics and semantic highlighting instead of your own grammar.

@RedCMD
Copy link
Contributor Author

RedCMD commented Nov 13, 2023

yeah, I'll make the schem handle the basics and let my language server handle the rest

switching to solely using semantic highlighting instead of textmate isn't an option for me
as semantic's cant handle bracket pair matching
and I think the string scope from json disables "autoClosingPairs" (cant re-enable with semantic's)
and I like the idea of textmate grammars highlighting textmate grammars

I'll look into making a PR soon

@aeschli aeschli added json JSON support issues feature-request Request for new features or functionality labels Dec 6, 2023
@aeschli aeschli changed the title Allow extensions to enable the builtin json-language-features extension on their own personal json languageId [json] Allow extensions to enable the builtin json-language-features extension on their own personal json languageId Dec 6, 2023
@aeschli aeschli added this to the Backlog milestone Dec 6, 2023
@vscodenpa vscodenpa added unreleased Patch has not yet been released in VS Code Insiders insiders-released Patch has been released in VS Code Insiders and removed unreleased Patch has not yet been released in VS Code Insiders labels Jan 30, 2024
@rzhao271 rzhao271 modified the milestones: Backlog, February 2024 Feb 19, 2024
@rzhao271 rzhao271 added the verification-needed Verification of issue is requested label Feb 19, 2024
@andreamah
Copy link
Contributor

@aeschli Do you have some minimal steps to verify this?

@RedCMD
Copy link
Contributor Author

RedCMD commented Feb 21, 2024

place this in an extensions package.json file
update languageId with a language to target
open a file with that language set
notice how all the json language features are available
Intellisense, formatting, diagnostics etc

"main": "",
"extensionDependencies": [
	"vscode.json-language-features"
],
"contributes": {
	"jsonLanguageParticipants": [
		{
			"languageId": "foobar"
		}
	]
} 

extensionDependencies activates the json-language-features extension
main is required for extensionDependencies to work

@alexr00 alexr00 added the verified Verification succeeded label Feb 21, 2024
@microsoft microsoft locked and limited conversation to collaborators Jun 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature-request Request for new features or functionality insiders-released Patch has been released in VS Code Insiders json JSON support issues verification-needed Verification of issue is requested verified Verification succeeded
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants