Skip to content

Use treesitter parser libraries

Ioannis Somos requested to merge observeroftime/neovim:treesitter into main

Closes #1 (closed)

The latest tree-sitter update (v0.22) has made it easier to build parser libraries.
One option would be to link against them but I don't think Neovim supports that.
The alternative I went for was to generate symlinks as mentioned in #1 (closed).

Updated parsers:

  • tree-sitter-bash
  • tree-sitter-c
  • tree-sitter-lua
  • tree-sitter-markdown
  • tree-sitter-python
  • tree-sitter-query
  • tree-sitter-vimdoc
Sample PKGBUILD for tree-sitter-query
pkgname=tree-sitter-query
pkgver=0.2.0
pkgrel=1
pkgdesc='TS query grammar for tree-sitter'
arch=('x86_64')
url='https://github.com/tree-sitter-grammars/tree-sitter-query'
license=('Apache')
groups=('tree-sitter-grammars')
provides=('libtree-sitter-query.so=0-64')
makedepends=('tree-sitter-cli' 'nodejs')
optdepends=('tree-sitter: core library')
source=("$pkgname-$pkgver.tar.gz::$url/archive/refs/tags/v${pkgver}.tar.gz")
sha256sums=('5a0ee26c4af94adb9ab850a518613f75e7040354f5b049a5b85457ebf579ae8b')

prepare() {
  cd "$pkgname-$pkgver"
  tree-sitter generate --no-bindings
}

build() {
  cd "$pkgname-$pkgver"
  make PREFIX=/usr
}

package() {
  cd "$pkgname-$pkgver"
  make DESTDIR="$pkgdir" PREFIX=/usr install
  install -Dm644 README.md -t "$pkgdir/usr/share/doc/$pkgname"
  install -Dm644 LICENSE -t "$pkgdir/usr/share/licenses/$pkgname"
}

The prepare step and makedepends were added just in case the existing src/parser.c is incompatible.

Edited by Ioannis Somos

Merge request reports

Loading