Metadata-Version: 2.4
Name: tree-sitter-off-taxonomy
Version: 0.2.4
Summary: Tree-sitter parser for Open Food Facts taxonomy files.
Author-email: Freso <dev@freso.dk>
License: AGPL-3.0-or-later
Project-URL: Homepage, https://codeberg.org/freso/tree-sitter-off_taxonomy
Project-URL: Funding, https://world.openfoodfacts.org/donate-to-open-food-facts
Keywords: incremental,parsing,tree-sitter,off-taxonomy
Classifier: Intended Audience :: Developers
Classifier: Topic :: Software Development :: Compilers
Classifier: Topic :: Text Processing :: Linguistic
Classifier: Typing :: Typed
Requires-Python: >=3.10
Description-Content-Type: text/x-rst
License-File: LICENSE.md
Provides-Extra: core
Requires-Dist: tree-sitter~=0.24; extra == "core"
Dynamic: license-file

.. SPDX-FileCopyrightText: © 2026 Freso <https://freso.dk/>
.. SPDX-License-Identifier: AGPL-3.0-or-later

================================================
 Tree-sitter for Open Food Facts taxonomy files
================================================

A `Tree-sitter`_ parser for parsing `Open Food Facts`_’s
`taxonomy`_ source files.

.. _Open Food Facts: https://world.openfoodfacts.org/
.. _taxonomy: https://wiki.openfoodfacts.org/Taxonomies_introduction

Usage
=====

Neovim (>= 0.12)
----------------

Make sure you already have `treesitter for Neovim`_ set up and working, and
this repository cloned somewhere locally. You will also need to run the
``tree-sitter`` commands in the Development section.

Insert something like the following in your Neovim configuration:

.. code:: lua

  -- Register off_taxonomy as a filetype
  vim.filetype.add({
    pattern = {
      ['.*/taxonomies/.*%.txt'] = {'off_taxonomy', { priority = 50 } },
    },
  })
  vim.treesitter.language.add('off_taxonomy', '/path/to/tree-sitter-off_taxonomy')
  vim.treesitter.language.register('off_taxonomy', {})

  -- Add treesitter directories to runtimepath
  vim.opt.runtimepath:prepend("/path/to/tree-sitter-off_taxonomy")

You may need to also set up some folders in the repository to provide the
proper directory structure Neovim expects:

.. code:: sh

   cd /path/to/tree-sitter-off_taxonomy
   mkdir parser
   cd parser
   ln -s ../off_treesitter.so
   cd ..
   cd queries
   ln -s . off_taxonomy

Alternatively you can create symlinks in ``$XDG_CONFIG_HOME/nvim/parser``
and/or ``…/queries`` or similar. See the `treesitter for Neovim`_ documentation
for details on where Neovim expects to find these files/directories.

.. _`treesitter for Neovim`: https://neovim.io/doc/user/treesitter/

Development
===========

Make sure you have `Tree-sitter`_ and its CLI and dependencies installed.
You should preferably also have `pre-commit`_ installed.

You generally want to do something like this to get started:

.. code:: sh

  # Clone the repository
  git clone https://codeberg.org/Freso/tree-sitter-off_taxonomy.git
  cd tree-sitter-off_taxonomy
  # Generate all the derived files
  tree-sitter init
  tree-sitter generate
  # Install pre-commit hooks
  pre-commit install
  # Run tests
  tree-sitter test
  # Tests also get run as part of pre-commit, so alternatively:
  pre-commit run --all-files

.. _Tree-sitter: https://tree-sitter.github.io/
.. _pre-commit: https://pre-commit.com/

Commit style
------------

`Keep commits atomic`_,
use `Conventional Commits`_ [*]_,
and write `good commit messages`_.

.. [*] Note that this project uses ``task:`` in place of ``chore:``.

.. _`Keep commits atomic`: https://www.freshconsulting.com/insights/blog/atomic-commits/
.. _`Conventional Commits`: https://www.conventionalcommits.org/en/v1.0.0/
.. _`good commit messages`: https://cbea.ms/git-commit/

---------
 License
---------

This Tree-sitter parser is `free software`_: you can redistribute it and/or
modify it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or (at your
option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along
with this program. If not, see <https://www.gnu.org/licenses/>.

**Some parts of the repository may be distributed under different terms.**
This project adheres to the `REUSE Specification`_ and any files
or code deviating from the general license of the project will be
annotated accordingly.

.. _`free software`: https://www.gnu.org/philosophy/free-sw.html
.. _`REUSE Specification`: https://reuse.software/spec-3.3/
