Swift API for the tree-sitter incremental parsing system.
- Close to full coverage of the C API
- Swift/Foundation types where possible
- Standard query result mapping for highlights and injections
- Query predicate support via
ResolvingQueryCursor
SwiftTreeSitter is fairly low-level. If you are looking a higher-level system for syntax highlighting and other syntactic operations, you might want to have a look at Neon.
📖 Documentation is available in DocC format.
dependencies: [
.package(url: "https://github.com/ChimeHQ/SwiftTreeSitter")
]
This is an experimental target that ties together a lot of the tree-sitter highlighting concepts into one easier-to-use library. It is currently experimental.
Tree-sitter language parsers are separate projects, and you'll probably need at least one. More details are available in the documentation. How they can be installed an incorporated varies. Since you're here, you might find SPM the most convenient.
Parser | Make | SPM | Official Repo |
---|---|---|---|
Bash | ✅ | ✅ | |
C | ✅ | ✅ | |
C++ | ✅ | ✅ | |
C# | ✅ | ✅ | |
Clojure | ✅ | ||
CMake | |||
Comment | |||
CSS | ✅ | ✅ | |
D | |||
Dart | |||
Dockerfile | ✅ | ✅ | ✅ |
Diff | ✅ | ✅ | |
Elixir | ✅ | ✅ | ✅ |
Elm | ✅ | ✅ | |
Erlang | |||
Fish | |||
Fortran | |||
gitattributes | |||
gitignore | |||
Go | ✅ | ✅ | ✅ |
GoMod | ✅ | ✅ | ✅ |
GoWork | ✅ | ||
graphql | |||
Hack | |||
Haskell | ✅ | ✅ | |
HCL | ✅ | ✅ | |
HTML | ✅ | ✅ | |
Java | ✅ | ✅ | ✅ |
Javascript | ✅ | ✅ | |
JSON | ✅ | ✅ | ✅ |
Json5 | |||
JSDoc | ✅ | ✅ | |
Julia | ✅ | ✅ | |
Kotlin | ✅ | ||
Latex | ✅ | ✅ | |
LLVM | |||
Lua | ✅ | ✅ | |
Make | |||
Markdown | ✅ | ✅ | |
Markdown | ✅ | ||
OCaml | ✅ | ✅ | |
Pascal | |||
Perl | ✅ | ✅ | |
PHP | ✅ | ✅ | ✅ |
PowerShell | |||
Python | ✅ | ✅ | |
R | |||
Racket | |||
Regex | |||
Ruby | ✅ | ✅ | ✅ |
Rust | ✅ | ✅ | |
Scala | ✅ | ✅ | |
Scheme | |||
Scss | |||
SQL | ✅ | ✅ | |
Sqlite | |||
SSH | ✅ | ✅ | |
Swift | ✅ | ✅ | ✅ |
TOML | ✅ | ||
Tree-sitter query language | ✅ | ✅ | |
Typescript | ✅ | ✅ | |
Verilog | ✅ | ✅ | |
Vue | |||
YAML | ✅ | ||
Zig | ✅ | ✅ | ✅ |
I'd love to hear from you! Get in touch via an issue or pull request.
I prefer collaboration, and would love to find ways to work together if you have a similar project.
I prefer indentation with tabs for improved accessibility. But, I'd rather you use the system you want and make a PR than hesitate because of whitespace.
By participating in this project you agree to abide by the Contributor Code of Conduct.