Tree-sitter grammar for Ora (.ora) source files.
Initial bootstrap grammar intended for editor integration and incremental improvement.
- Source of truth for compiler semantics remains Ora's handwritten parser.
- This grammar is for editor-facing parsing (highlighting, structure, and future LSP plumbing).
- Node.js + npm
tree-sitter-cli(via npm dev dependency)
cd tree-sitter-ora
pnpm install
pnpm run generate
pnpm testEquivalent with npm:
cd tree-sitter-ora
npm install
npm run generate
npm testFrom repo root:
./scripts/test-tree-sitter.shAdd parser config:
local parsers = require("nvim-treesitter.parsers")
parsers.ora = {
install_info = {
url = "/Users/logic/Ora/Ora/tree-sitter-ora",
files = { "src/parser.c" },
generate_requires_npm = true,
requires_generate_from_grammar = true,
},
filetype = "ora",
}
vim.filetype.add({ extension = { ora = "ora" } })
require("nvim-treesitter").setup({})
require("nvim-treesitter").install({ "ora" })Then run in Neovim:
:TSInstall oraqueries/highlights.scm includes captures for:
- Core language: contracts, structs, enums, errors, functions, operators.
- Regions:
storage,memory,tstore,calldatawith dedicated variable captures. - Formal verification:
requires,ensures,invariant,decreases, quantifiers. - Comptime: comptime keyword, comptime parameters, and comptime functions.
- Builtins:
std.*namespaces (constants,msg,transaction,block) and intrinsic calls (@addWithOverflow,@lock, etc.). - Ghost and verification constructs.
Useful custom links in Neovim:
vim.api.nvim_set_hl(0, "@function.comptime.ora", { bold = true })
vim.api.nvim_set_hl(0, "@module.builtin.ora", { italic = true })
vim.api.nvim_set_hl(0, "@function.builtin.ora", { bold = true })
vim.api.nvim_set_hl(0, "@constant.builtin.ora", { bold = true })
vim.api.nvim_set_hl(0, "@keyword.fv.ora", { italic = true })
vim.api.nvim_set_hl(0, "@keyword.ghost.ora", { italic = true })Full example file:
examples/nvim/ora_highlights.lua
Usage from your init.lua:
local ora_hl = dofile("/absolute/path/to/tree-sitter-ora/examples/nvim/ora_highlights.lua")
ora_hl.autocmd()Optional palette override:
local ora_hl = dofile("/absolute/path/to/tree-sitter-ora/examples/nvim/ora_highlights.lua")
ora_hl.autocmd({
palette = {
red = "#ff6b6b",
cyan = "#63e6be",
},
})Notes:
- By default, highlights are scoped to
.oracaptures only (@capture.ora). - Pass
{ global = true }to also set non-language-scoped captures (affects other filetypes).
grammar.js: grammar definitiontree-sitter.json: parser metadataqueries/highlights.scm: highlight capturestest/corpus/*.txt: corpus testssrc/: generated parser artifacts (parser.c,node-types.json) aftertree-sitter generate
If pnpm run generate fails with missing tree-sitter-cli/tree-sitter (ENOENT), dependency build scripts were skipped.
Run:
cd tree-sitter-ora
pnpm approve-builds tree-sitter-cli
pnpm rebuild tree-sitter-cli
pnpm run generateIf needed:
pnpm install --ignore-scripts=false