{"id":13668515,"url":"https://github.com/novusnota/tree-sitter-ohm","last_synced_at":"2026-05-20T02:43:25.428Z","repository":{"id":225207845,"uuid":"759148868","full_name":"novusnota/tree-sitter-ohm","owner":"novusnota","description":"🌳 Tree-sitter grammar for the Ohm domain-specific language. Quickly build parsers, interpreters, and compilers for programming languages with Ohm's parsing toolkit!","archived":false,"fork":false,"pushed_at":"2024-03-24T20:27:43.000Z","size":76,"stargazers_count":2,"open_issues_count":5,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-23T20:44:16.317Z","etag":null,"topics":["compilers","interpreters","ohm","ohmjs","parsers","parsing-expression-grammar","peg","tree-sitter","tree-sitter-parser"],"latest_commit_sha":null,"homepage":"https://ohmjs.org/","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/novusnota.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-02-17T19:27:38.000Z","updated_at":"2025-01-21T16:47:08.000Z","dependencies_parsed_at":"2024-02-29T20:26:04.762Z","dependency_job_id":"67f78115-3031-4f67-92f2-3178299d9da1","html_url":"https://github.com/novusnota/tree-sitter-ohm","commit_stats":null,"previous_names":["novusnota/tree-sitter-ohm"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/novusnota%2Ftree-sitter-ohm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/novusnota%2Ftree-sitter-ohm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/novusnota%2Ftree-sitter-ohm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/novusnota%2Ftree-sitter-ohm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/novusnota","download_url":"https://codeload.github.com/novusnota/tree-sitter-ohm/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244022724,"owners_count":20385134,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["compilers","interpreters","ohm","ohmjs","parsers","parsing-expression-grammar","peg","tree-sitter","tree-sitter-parser"],"created_at":"2024-08-02T08:00:39.357Z","updated_at":"2026-05-20T02:43:20.392Z","avatar_url":"https://github.com/novusnota.png","language":"C","funding_links":[],"categories":["Developer tools"],"sub_categories":[],"readme":"# tree-sitter-ohm\n\n🌳 Tree-sitter grammar for the Ohm domain-specific language. Quickly build parsers, interpreters, and compilers for programming languages with Ohm's parsing toolkit!\n\n## 🎨 Structure\n\nGrammar definition resides in `grammar.js`:\n\n- Actual grammar and bindings are generated from it via Tree-sitter.\n- Queries and tests rely on its namings of nodes and fields.\n\nGeneric queries are structured as follows:\n\n```\nqueries/\n|-- highlights.scm -- syntax highlighting queries (generic, for Tree-sitter \u0026 GitHub)\n|-- locals.scm -- fixed set of capture names to track local scopes and variables (and alike)\n|-- injections.scm -- specification for embedded syntaxes (mainly used for TODO/FIXME highlighting in comments)\n`-- tags.scm -- tagging queries for code navigation systems (as used on GitHub)\n```\n\nTo find highlighting and other queries for specific editors, look in the `editor_queries/` directory.\n\n## 🚀 Usage\n\n### Neovim\n\nInstallation assumes you're using [`lazy.nvim`](https://github.com/folke/lazy.nvim) as a plugin manager:\n\n\u003cdetails\u003e\n\u003csummary\u003eInstructions\u003c/summary\u003e\n\n1. Clone the repo to any convenient place: `git clone https://github.com/novusnota/tree-sitter-ohm ~/.local/git/tree-sitter-ohm` (`~/.local/git` is exemplary, you may choose another directory)\n\n2. Add the following (partly or as a whole) to your `~/.config/nvim/init.lua` (Or `~\\AppData\\Local\\nvim\\init.lua` on Windows):\n\nFor the general Tree-sitter support:\n\n```lua\n-- lazy.nvim package manager\nrequire('lazy').setup({\n  -- ...\n\t{\n    -- Highlight, edit, and navigate code\n    'nvim-treesitter/nvim-treesitter',\n    build = ':TSUpdate',\n\n    -- Optional, may be removed:\n    dependencies = {\n      -- adds syntax aware text-objects, select, move, swap, and peek support\n      -- see: https://github.com/nvim-treesitter/nvim-treesitter-textobjects\n      'nvim-treesitter/nvim-treesitter-textobjects',\n\n      -- adds a sticky context header on top as you scroll through file contents\n      -- see: https://github.com/nvim-treesitter/nvim-treesitter-context\n      'nvim-treesitter/nvim-treesitter-context'\n    },\n  },\n  -- ...\n}, {})\n```\n\nFor the tree-sitter-ohm support:\n\n```lua\nlocal parser_config = require \"nvim-treesitter.parsers\".get_parser_configs()\n\n-- Adds tree-sitter-ohm support\nparser_config.ohm = {\n  install_info = {\n    url = \"~/.local/git/tree-sitter-ohm\", -- a path to the cloned repo\n    files = {\"src/parser.c\", \"src/scanner.c\"},\n    branch = \"main\",\n    generate_requires_npm = false,\n    requires_generate_from_grammar = false,\n  }\n}\n\n-- Adds filetype recognition for .ohm files and simple indentation rules\nvim.api.nvim_create_autocmd({\"BufEnter\", \"BufWinEnter\"}, {\n  pattern = \"*.ohm\",\n  callback = function()\n    vim.bo.filetype = \"ohm\"\n    vim.bo.expandtab = true\n    vim.bo.softtabstop = 2\n    vim.bo.shiftwidth = 2\n  end\n})\n```\n\n3. Create a folder for queries under your Neovim runtime directory, if not exists:\n  * Windows: `mkdir -p ~\\AppData\\Local\\nvim\\queries`\n  * Linux, macOS, *NIX: `mkdir -p ~/.config/nvim/queries`\n\n4. Symlink the `editor_queries/neovim` sub-directory, this will add all the queries:\n  * Windows: `mklink /D ~\\AppData\\Local\\nvim\\queries\\ohm ~\\.local\\git\\tree-sitter-ohm\\editor_queries\\neovim`\n  * Linux, macOS, *NIX: `ln -s ~/.local/git/tree-sitter-ohm/editor_queries/neovim ~/.config/nvim/queries/ohm`\n\n5. Finally, run the `:TSInstall ohm` inside the Neovim.\n\n6. For further configuration and customization, refer to the following repositories:\n* [nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter)\n* [nvim-treesitter-textobjects](https://github.com/nvim-treesitter/nvim-treesitter-textobjects)\n* [nvim-treesitter-context](https://github.com/nvim-treesitter/nvim-treesitter-context)\n\n\u003c/details\u003e\n\nQueries bundled (see `editor_queries/neovim`):\n* `highlights.scm` — syntax highlighting\n* `locals.scm` — used to extract keyword definitions, scopes, references, etc., but NOT used for highlighting (unlike Generic or Helix queries)\n* `injections.scm` — highlighting of TODO, FIXME and related in single-line comments\n* `folds.scm` — syntax folds (note, that folding has to be enabled in config in order to use those)\n* `indents.scm` — indentation levels\n* `textobjects.scm` — syntax aware text-objects, select, move, swap, and peek support.\n* `context.scm` — shows sticky context on top of the editor as you scroll through file contents\n\n### Helix\n\n\u003cdetails\u003e\n\u003csummary\u003eInstructions\u003c/summary\u003e\n\n1. Clone the repo to any convenient place: `git clone https://github.com/novusnota/tree-sitter-ohm ~/.local/git/tree-sitter-ohm` (`~/.local/git` is exemplary, you may choose another directory)\n\n2. Create a folder for queries under your Helix runtime directory, if not exists:\n  * Windows: `mkdir -p ~\\AppData\\Roaming\\helix\\runtime\\queries`\n  * Linux, macOS, *NIX: `mkdir -p ~/.config/helix/runtime/queries`\n\n3. Symlink the `editor_queries/helix` sub-directory, this will add all the queries:\n  * Windows: `mklink /D ~\\AppData\\Roaming\\helix\\runtime\\queries\\ohm ~\\.local\\git\\tree-sitter-ohm\\editor_queries\\helix`\n  * Linux, macOS, *NIX: `ln -s ~/.local/git/tree-sitter-ohm/editor_queries/helix ~/.config/helix/runtime/queries/ohm`\n\n4. Add the following to your `~/.config/helix/languages.toml` (Or `~\\AppData\\Roaming\\helix\\languages.toml` on Windows):\n\n```toml\n[[language]]\nname = \"ohm\"\nscope = \"source.ohm\"\ninjection-regex = \"ohm\"\nfile-types = [\"ohm\"]\ncomment-token = \"//\"\nindent = { tab-width = 2, unit = \"  \" }\nroots = []\n\n[language.auto-pairs]\n'\"' = '\"'\n'{' = '}'\n'(' = ')'\n'\u003c' = '\u003e'\n\n[[grammar]]\nname = \"ohm\"\nsource = { path = \"/absolute/path/to/your/home/directory/.local/git/tree-sitter-ohm\" }  # TODO: replace with your full path to downloaded repo\n```\n\n5. Finally, run the following commands to update all Tree-sitter grammars, including ohm's:\n\n```bash\nhx --grammar fetch\nhx --grammar build\n```\n\n\u003c/details\u003e\n\nQueries bundled (see `editor_queries/helix`):\n* `highlights.scm` — syntax highlighting\n* `injections.scm` — highlighting of TODO, FIXME and related in single-line comments\n* `indents.scm` — indentation levels\n* `textobjects.scm` — syntax aware text-objects\n\n## 💲 CLI Usage\n\nTree-sitter grammars have limited utility on their own and are best used as parsers that can be embedded in other projects. However, [tree-sitter-cli](https://github.com/tree-sitter/tree-sitter/blob/master/cli/README.md) can be used with this grammar to show generated parse trees and syntax highlighting for a given ohm file.\n\nFor a quick demo of tree-sitter-cli usage:\n1. Clone this repo.\n2. Install Node.js dependencies (by `npm i`, `pnpm i` or `yarn`).\n3. Execute relevant commands from the `scripts` tag in `package.json`.\n\nFor a more streamlined experience, you may:\n1. [Install tree-sitter-cli](https://github.com/tree-sitter/tree-sitter/blob/master/cli/README.md#installation).\n2. Create a `tree-sitters` directory in your home directory.\n3. Clone this repository (or symlink it) into the new `~/tree-sitters/` directory.\n4. Run `tree-sitter parse path/to/file.ohm` to be shown the parse tree for the file.\n5. Run `tree-sitter highlight path/to/file.ohm` to be shown the file with syntax highlighting applied.\n\n## ⚙ References\n\n- [ohm-grammar.ohm](https://github.com/ohmjs/ohm/blob/main/packages/ohm-js/src/ohm-grammar.ohm) — Official grammar specification of Ohm PEG language, written itself in Ohm!\n\n## Useful Ohm links\n\n- [Official Website](https://ohmjs.org/)\n- [GitHub.com Source](https://github.com/ohmjs/ohm)\n- [Awesome Ohm list](https://github.com/ohmjs/awesome-ohm)\n- [VSCode extension](https://github.com/novusnota/vscode-ohm)\n\n## Credits\n\nExamples in `test/sample` directory are taken from [ohmjs/ohm](https://github.com/ohmjs/ohm) under MIT license.\n\nBuilt with 🤍 by [Novus Nota](https://github.com/novusnota)\n\n## License\n\n[MIT](LICENSE)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnovusnota%2Ftree-sitter-ohm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnovusnota%2Ftree-sitter-ohm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnovusnota%2Ftree-sitter-ohm/lists"}