https://github.com/jtbandes/swift-tmlanguage
Swift language grammar for syntax highlighting
https://github.com/jtbandes/swift-tmlanguage
Last synced: 4 months ago
JSON representation
Swift language grammar for syntax highlighting
- Host: GitHub
- URL: https://github.com/jtbandes/swift-tmlanguage
- Owner: jtbandes
- License: mit
- Created: 2023-11-02T05:10:16.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-01-19T01:20:49.000Z (6 months ago)
- Last Synced: 2025-02-28T07:32:19.499Z (4 months ago)
- Language: YAML
- Homepage:
- Size: 710 KB
- Stars: 9
- Watchers: 2
- Forks: 1
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Swift language grammar
**Swift.tmLanguage** is a TextMate [language grammar](https://macromates.com/manual/en/language_grammars) for the [Swift programming language](https://www.swift.org). It defines regex-based parsing rules so that code renderers can [highlight](https://en.wikipedia.org/wiki/Syntax_highlighting) Swift code using a semantic color scheme.
This grammar is used for syntax highlighting by:
- **Visual Studio Code** — as part of the [built-in extension](https://github.com/microsoft/vscode/tree/main/extensions/swift) for basic language support, **not** in the full-featured [`vscode-swift` extension](https://github.com/swift-server/vscode-swift)
- [**Shiki**](https://shiki.style) — via the [`tm-grammars` package](https://github.com/shikijs/textmate-grammars-themes)(It was also used by GitHub [Linguist](https://github.com/github-linguist/linguist) until 2024.)
The language grammar is available in three formats:
- [Swift.tmLanguage.yaml](Swift.tmLanguage.yaml) — the canonical copy intended for human editing
- [Swift.tmLanguage.json](Swift.tmLanguage.json) — generated from the YAML
- [Swift.tmLanguage](Syntaxes/Swift.tmLanguage) — generated from the JSON## Development
- Run `yarn install` to install dependencies.
- After making changes to the YAML grammar, run `yarn build` to regenerate the `.tmLanguage.json` and `.tmLanguage` files.
- To test the grammar in VS Code, press F5 to load the current version of the `.tmLanguage` in a new window. After each `yarn build`, reload the window to load the updated `.tmLanguage`. (If you have the [`vscode-swift` extension](https://github.com/swift-server/vscode-swift) installed, you'll need to disable it so it doesn't override the scopes provided by the `.tmLanguage` grammar.)
## Maintenance status
The Swift grammar was developed for years at [textmate/swift.tmbundle](https://github.com/textmate/swift.tmbundle), which is no longer actively maintained. Development of the grammar continues here.
This grammar is maintained by [**@jtbandes**](https://github.com/jtbandes) as a passion project. If you'd like to support past and future development, please consider [making a donation](https://github.com/sponsors/jtbandes). 💖
## License
This project is licensed under the terms of the [MIT license](LICENSE.md).