A Tree-sitter parser for parsing Open Food Facts’s taxonomy source files.
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:
-- 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:
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.
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:
# 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
Commit style
Keep commits atomic, use Conventional Commits [*], and write good commit messages.
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.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file tree_sitter_off_taxonomy-0.2.5.tar.gz.
File metadata
- Download URL: tree_sitter_off_taxonomy-0.2.5.tar.gz
- Upload date:
- Size: 28.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.14.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
caa396ba82292d23a696fb6799eb70299c61038181b9876befc4366cd145ba52
|
|
| MD5 |
70fbe07b64d628f98c358dfce5dedec8
|
|
| BLAKE2b-256 |
22198a69628a55f5e341536c1935f5a0c2f7527a341ddf83897302a9781cc689
|