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

How to make the embedded language have corresponding language id #216

Open
BeishaoCao-db opened this issue Oct 27, 2023 · 1 comment
Open

Comments

@BeishaoCao-db
Copy link

BeishaoCao-db commented Oct 27, 2023

Hello everyone, I am struggling to find a correct way to support Textmate grammar with embedded language. For example, I want to embed sql into python and all the code inside sql( and ) should be considered as SQL code.

I add custom grammar rule to MagicPython grammer file and successfully make the token returned by tokenizeLine have SQL grammar scope name (something like *.sql). However, I don't know how to make the token returned by tokenizeLine2 to have language sql rather than python

e.g.
For SELECT in sql(SELECT):
tokenizeLine will return: keyword.other.DML.sql, which is defined in Sql.tmLanguage.json
tokenizeLine2 will return a Uint32Array, but the mask the array will show language is python rather than sql

Any idea about how to fix this? I appreciate any help and understand there are a lot of moving parts here to make this all work!

@RedCMD
Copy link

RedCMD commented Oct 5, 2024

use loadGrammarWithConfiguration() or loadGrammarWithEmbeddedLanguages() with IEmbeddedLanguagesMap instead of loadGrammar()

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

2 participants