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

Restriction of injection grammars for specific filename #200248

Closed
anticultist opened this issue Dec 7, 2023 · 5 comments
Closed

Restriction of injection grammars for specific filename #200248

anticultist opened this issue Dec 7, 2023 · 5 comments
Assignees
Labels
feature-request Request for new features or functionality grammar Syntax highlighting grammar *out-of-scope Posted issue is not in scope of VS Code

Comments

@anticultist
Copy link

I can not find a way to restrict injected syntax highlighting to specific files like foo.json.

In my use case I want extend syntax highlighting in dictionary string values of specific JSON files with a fixed file name. The syntax highlighting works fine but it is also enabled in other JSON files I do not want them to be enabled. Is there a way to restrict injected syntax highlighting to a specific file name or do I have to create a language server?

@RedCMD
Copy link
Contributor

RedCMD commented Dec 7, 2023

Currently there is no easy way
Either create a language server and use semantic highlighting (which won't have bracket highlighting support)
or
create a new languageId; allowing you to define "filenamePatterns"
Include source.json and then you can inject into your languageId

@anticultist
Copy link
Author

Thanks for the quick response!

I try to stick with the json languageId because I want to keep other nice features like json schema support. I suppose it is only enabled for the json languageId.
So it sounds like I have to go the language server route, which I thought I could try to avoid.
Is there any chance that restriction of injected grammars for specific filename could be considered as a new feature?

@RedCMD
Copy link
Contributor

RedCMD commented Dec 7, 2023

I am trying to get this through #198583 to enable schema support etc for other json languageId's

@aeschli
Copy link
Contributor

aeschli commented Dec 8, 2023

Using semantic highlighting sounds like the best approach to me.

@aeschli
Copy link
Contributor

aeschli commented Dec 8, 2023

Closing the issue. No plans to make injections per file name.

@aeschli aeschli closed this as completed Dec 8, 2023
@aeschli aeschli added grammar Syntax highlighting grammar feature-request Request for new features or functionality *out-of-scope Posted issue is not in scope of VS Code labels Dec 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request Request for new features or functionality grammar Syntax highlighting grammar *out-of-scope Posted issue is not in scope of VS Code
Projects
None yet
Development

No branches or pull requests

3 participants