Skip to content

ap29600/tree-sitter-odin

 
 

Repository files navigation

tree-sitter-odin

a tree-sitter grammar for the Odin programming language

What is this?

tree-sitter is a parser generator tool. This grammar can be used to generate a parser for the Odin programming language for the purpose of syntax highlighting and editor integration.

Why use this over regex-based syntax highlighting?

tree-sitter-generated parsers are context-aware, which means that the highlighting is more faithful to the actual meaning of the code, helping you catch syntax errors at a glance.

Moreover, a capable editor can query tree-sitter's output to give you better indentation and incremental selection.

How do I use this?

Linux

Neovim

install the nvim-treesitter plugin and add the following snippet to your neovim config:

lua << EOF

local parser_config = require "nvim-treesitter.parsers".get_parser_configs()
parser_config.odin = {
  install_info = {
    url = "path/to/tree-sitter-odin",
    branch = 'main',
    files = {"src/parser.c"}
  },
  filetype = "odin",
}

EOF

as well as copying or symlinking the queries/ directory of this repository to <your nvim config location>/queries/odin/, and making sure that the odin filetype is correctly detected by neovim.

Helix

Helix requires that you specify your syntaxes at compile-time, so you will need to clone the helix repository.

Helix already ships with a different tree-sitter grammar for Odin; to use this one, modify the languages.scm file in the helix repository and replace the lines:

[[grammar]]
name = "odin"
source = { git = "https://github.com/MineBill/tree-sitter-odin", rev = "da885f4a387f169b9b69fe0968259ee257a8f69a" }

with

[[grammar]]
name = "odin"
source = { path = "path/to/tree-sitter-odin" }

as well as copying or symlinking the queries/ directory of this repository to <your helix config location>/runtime/queries/odin/; lastly rebuild helix from source.

About

Odin grammar for tree-sitter

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 99.6%
  • JavaScript 0.4%
  • Rust 0.0%
  • Scheme 0.0%
  • C++ 0.0%
  • Python 0.0%