-
Notifications
You must be signed in to change notification settings - Fork 29.7k
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
Allow dynamic location of textmate grammar #68647
Comments
I find it very interesting, I wasn't aware of the tricks you are doing with rewriting your grammar! I think referring in Adding imperative API seems like the way to go, since you could call the API whenever you are ready. But... this would have the disadvantage of not coloring those blocks each and every time until after your extension activates and uses the API... To be honest, I find both proposals have flaws... |
That's actually ok for me, most people don't change the custom blocks frequently.
What do you think about adding a setting and putting the grammar to user repo? When no grammar is found, Vue files fallback to using grammar bundled in extension. Also, custom blocks tie to specific dependencies. For example, people use |
@alexandrudima What is the plan for this issue? I am working on a language server for domain specific languages. Once the language grammar is created, extension is generated and installed. It works very well, without need to reload a window. |
@alexandrudima I was wondering if you have had a chance to look at this feature? |
I'm a contributor on an extension called MV Basic that provides language support for a language (PickBASIC) that, depending on the vendor/flavor in use, has different language definitions and syntax highlighting requirements. The language definitions are readily solved for by loading them at runtime in the language server, leveraging a configuration setting we've added to the extension, but dynamically switching the grammar has been a bit tougher given the discussion above. Adding my vote into the equation for having a route to specifying the grammar via API. I concede the trade off in needing the extension to activate and call the API, but we're effectively there anyway with respect to the language definition itself. |
@itsxallwater I found a workaround using setDecorations method, although it requires much more work. Here are some implementation details if you find this helpful. |
Is there some sort of regex to determine if filename or directory path includes a certain match? Context: I'm writing a Rails syntax ruby language injection extension and running into similar issues. For example, certain methods are only available for |
any chance semantic highlighting could hackily cover this? https://code.visualstudio.com/api/language-extensions/semantic-highlight-guide |
From my understanding, semantic highlighting gives you more color variation to match things such as parameters to variables etc. It seems to allow for modifying the current token type after looking at the reference https://github.com/microsoft/vscode-extension-samples/blob/master/semantic-tokens-sample/src/extension.ts . I haven't fully grasped the VS Code docs on the semantic highlighting if it would allow for a dynamic location. |
I wanted to open a new ticket, but found the existing one! I also have a strong need for dynamic grammar generation.
Both Vim and Sublime Text 3 editors support dynamic syntax generation; this mechanism is widely used in Vim by parenthesis highlighting extensions. |
Just wanted to voice my support of this issue as well as the maintainer of the Angular Language Service extension for VSCode. Components can define inline styles and since version 12, styles other than CSS (Sass, Less, Styl) can be used inline. I updated our style highlighting recently to assume SCSS for inline styles to support more use-cases, but it would be nice to be able to do the actual right thing and provide the correct language highlighting for inline styles, either by extension config or programmatically in the extension itself. |
Ref: vuejs/vetur#210
In Vue files you can have
<template>
,<style>
and<script>
tag.However, certain libraries can add top-level custom blocks that uses another language. For example:
Our approach was:
vetur.grammar.customBlocks
package.json
This has been working, but I'm worried extension integrity check might kick in and ask for reinstall. Also @sandy081 mentioned updates remove the old folder, so it's bad to keep states in extension directory.
What I need is a path that I can:
package.json
)So the paths in
ExtensionContext
wouldn't work for me.After checking with @sandy081, we think offering an API like
languages.setGrammar
would be best. We considered allowing path interpolations like${globalStoragePath}/grammars/vue.json
inpackage.json
, but that means the best Vetur can do is to write to that path on first activation, so no coloring before first activation/reload.However, I'm not sure we should provide an API tied to TextMate grammar. Also the API means the dynamically generated TextMate grammar wouldn't be loaded until extension activation.
@alexandrudima What do you think?
The text was updated successfully, but these errors were encountered: