Treesitter for sproto
This repository provides a Tree-sitter grammar for the sproto serialization protocol. With this grammar, you can enable advanced syntax highlighting, code folding, and structural analysis for sproto files in editors and tools that support Tree-sitter, such as Neovim (via nvim-treesitter).
- Syntax highlighting for sproto files.
- Tree-sitter queries for advanced code navigation.
- Multi-language bindings (Node.js, Python, Rust, Go, Swift).
- Easily integratable with editor plugins (like nvim-treesitter).
- Node.js (for development and testing)
- Tree-sitter CLI
- Your preferred editor with Tree-sitter support (e.g., Neovim)
Add tree-sitter-sproto to your nvim-treesitter configuration:
require'nvim-treesitter.parsers'.get_parser_configs().sproto = {
install_info = {
url = "https://github.com/hanxi/tree-sitter-sproto",
files = {"src/parser.c"}
},
filetype = "sproto",
}Clone the repository and build the parser:
git clone https://github.com/hanxi/tree-sitter-sproto.git
cd tree-sitter-sproto
npm install
npm run buildAfter building, you can use the generated parser in any tool that accepts Tree-sitter grammars. For editor integration, follow the instructions of the relevant plugin.
- Grammar is defined in
grammar.js - See
tree-sitter.jsonfor parser configuration. - Multiple build systems supported:
Makefile,CMakeLists.txt,Cargo.toml,setup.py,go.mod,Package.swift.
To generate parser source files:
npx tree-sitter generateContributions are welcome! Please create issues or PRs if you find bugs or want to improve the grammar.
MIT or same as Tree-sitter (see LICENSE if present).