From 0acc4dbba472491d62125a62439b5cb10611012a Mon Sep 17 00:00:00 2001 From: xenia Date: Sun, 12 Nov 2023 14:36:27 +0100 Subject: [PATCH] Add agda, nix --- Cargo.toml | 3 ++- build.rs | 4 ++++ flake.nix | 4 ++-- src/ffi.rs | 8 ++++++++ 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 0f6c441..b2988f4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -65,4 +65,5 @@ ruby = [] rust = [] scala = [] typescript = [] - +nix = [] +agda = [] diff --git a/build.rs b/build.rs index fae59e8..6987a3f 100644 --- a/build.rs +++ b/build.rs @@ -45,6 +45,10 @@ fn main() { "scala", #[cfg(feature = "typescript")] "typescript", + #[cfg(feature = "nix")] + "nix", + #[cfg(feature = "agda")] + "agda", ] { println!("cargo:rustc-link-lib=static=tree-sitter-{lang}"); } diff --git a/flake.nix b/flake.nix index 481b5eb..1757f25 100644 --- a/flake.nix +++ b/flake.nix @@ -22,14 +22,14 @@ }; sitters = tree-sitters.packages.${sys}; sitterlist = [ - sitters.agda sitters.bash sitters.c sitters.nix sitters.python sitters.rust + sitters.bash sitters.c sitters.python sitters.rust sitters.nix sitters.agda ]; kak-tree-bin = platform.buildRustPackage { name = "kak-tree-bin"; src = ./.; cargoLock = { lockFile = ./Cargo.lock; }; - buildFeatures = ["bash" "c" "python" "rust"]; # TODO: Add agda, nix + buildFeatures = ["bash" "c" "python" "rust" "nix" "agda"]; inherit sitterlist; preBuild = '' mkdir lib diff --git a/src/ffi.rs b/src/ffi.rs index c96641c..ad6ac0b 100644 --- a/src/ffi.rs +++ b/src/ffi.rs @@ -45,6 +45,10 @@ extern "C" { fn tree_sitter_scala() -> Language; #[cfg(feature = "typescript")] fn tree_sitter_typescript() -> Language; + #[cfg(feature = "nix")] + fn tree_sitter_nix() -> Language; + #[cfg(feature = "agda")] + fn tree_sitter_agda() -> Language; } pub fn filetype_to_language(filetype: &str) -> Option { @@ -93,6 +97,10 @@ pub fn filetype_to_language(filetype: &str) -> Option { "scala" => tree_sitter_scala, #[cfg(feature = "typescript")] "typescript" => tree_sitter_typescript, + #[cfg(feature = "nix")] + "nix" => tree_sitter_nix, + #[cfg(feature = "agda")] + "agda" => tree_sitter_agda, _ => return None, }; Some(unsafe { sitter() })