Skip to content

Allow users to define where to find tree sitter libraries#10

Draft
diasbruno wants to merge 1 commit intodeath:masterfrom
diasbruno:fixed/allow-users-to-define-where-to-find-tree-sitter-libraries
Draft

Allow users to define where to find tree sitter libraries#10
diasbruno wants to merge 1 commit intodeath:masterfrom
diasbruno:fixed/allow-users-to-define-where-to-find-tree-sitter-libraries

Conversation

@diasbruno
Copy link
Contributor

@diasbruno diasbruno commented Nov 4, 2023

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() {}")

@diasbruno
Copy link
Contributor Author

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.

@diasbruno
Copy link
Contributor Author

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.)

@diasbruno diasbruno force-pushed the fixed/allow-users-to-define-where-to-find-tree-sitter-libraries branch 4 times, most recently from 7f334dc to 1282f1c Compare November 10, 2023 11:41
@diasbruno
Copy link
Contributor Author

This works, but I think it can be cleaner.

@diasbruno diasbruno force-pushed the fixed/allow-users-to-define-where-to-find-tree-sitter-libraries branch from 1282f1c to e6bbbf1 Compare November 25, 2023 16:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant