-
Notifications
You must be signed in to change notification settings - Fork 74
Add language support for GYB #1515
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for putting this together, it's a great start! Unfortunately, I'm no expert when it comes to the language grammars in VS Code. Is there any way we could add tests for this at all?
CI is failing due to formatting issues. You'll want to run the following and push the changes:
npx prettier . --write
The unacceptable language filter also doesn't like the use of the word master
in the tmLanguage file. However, since there's no way to get around using that schema, you can add syntaxes/swift-gyb.tmLanguage.json
to the .unacceptablelanguageignore
file.
Microsoft recommends using this package to test the grammar. |
Oh and I just realized that you'll need to add the new language files to the
|
I added some tests using the package I mentioned previously. To run them in my dev container I use the command:
What do I have to do to make the tests run automatically? |
You'll want to create a new script in the {
"scripts": {
// ...
"test": "vscode-test && npm run grammar-test",
"grammar-test": "vscode-tmgrammar-test 'test/unit-tests/**/*.test.swift.gyb' -g test/unit-tests/syntaxes/swift.tmLanguage.json -g test/unit-tests/syntaxes/MagicPython.tmLanguage.json"
// ...
}
} |
Add syntax highlighting and language configuration for Swift GYB (
.swift.gyb
) files.Motivation:
Resolves #1455
Language support for GYB can't be implemented via
sourcekit-lsp
, as GYB can contain arbitrary Python.The TextMate grammar can't be an injection grammar because GYB files have a different file extension from normal Swift files, and also because
sourcekit-lsp
would activate and throw a lot of errors.Additions:
swift-gyb
language inpackage.json
.swift.gyb
filesKnown issues:
%{...}%
) and control statements (% keyword: ... % end
) are not always highlighted when they are inside Swift bodies (struct
s,extension
s andfunc
s, in other words when not in the top level of the file) and do not have at least one level of indentation.