Skip to content

Repository files navigation

tree-sitter-sproto

GitHub

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).

Features

  • 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).

Getting Started

Requirements

  • Node.js (for development and testing)
  • Tree-sitter CLI
  • Your preferred editor with Tree-sitter support (e.g., Neovim)

Installation

For Neovim (via nvim-treesitter)

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",
}

Building Locally

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 build

Usage

After 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.

Development

  • Grammar is defined in grammar.js
  • See tree-sitter.json for 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 generate

Contributing

Contributions are welcome! Please create issues or PRs if you find bugs or want to improve the grammar.

License

MIT or same as Tree-sitter (see LICENSE if present).

Links

About

Treesitter for sproto

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages