cl-tree-sitter
cl-tree-sitter copied to clipboard
Allow users to define where to find tree sitter libraries
This helps in case packages are installed on non-standard places (e.g. using nix).
This is an example of how to glue things together:
(push "../cl-tree-sitter/" ql:*local-project-directories*)
(push *default-pathname-defaults* ql:*local-project-directories*)
(ql:quickload :cl-tree-sitter.config)
(cl-tree-sitter.config:define-tree-sitter-path "/nix/store/jkmvpg3d3mvj72qmzdwipf01bx4kgxi9-tree-sitter-0.20.8/lib/libtree-sitter.dylib")
(cl-tree-sitter.config:define-tree-sitter-wrapper-path "./cl-tree-sitter/tree-sitter-wrapper.so")
(ql:quickload :cl-tree-sitter)
(cl-tree-sitter:register-language :kotlin
"./tree-sitter-kotlin/libtree-sitter-kotlin"
:fn-name "tree_sitter_kotlin")
(cl-tree-sitter:parse-string :kotlin "fun a() {}")
grovel seems to have nice integration with pkg-config.
(define-grovel-syntax pkg-config-cflags (pkg &key optional) ...)
Maybe this can make things easier to handle.
I've found a "nice" way to work with nix.
{ nixpkgs ? import <nixpkgs> {} }:
let
inherit (nixpkgs) pkgs;
in pkgs.mkShell {
nativeBuildInputs = with pkgs; [pkg-config libffi tree-sitter sbcl];
buildInputs = with pkgs.lispPackages; [quicklisp];
# this will make libraries available for compilers
# on shell mode
LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath [ pkgs.tree-sitter ];
}
This will work for some case, but if you compile something from source, this patch is still relevant for projects that install libraries outside of standard location (e.g /opt/lib.)
This works, but I think it can be cleaner.