From 0bd6770da4dc998dab2187a78b911da6dd661838 Mon Sep 17 00:00:00 2001 From: Ade Attwood Date: Fri, 9 Jun 2023 19:07:01 +0100 Subject: [PATCH] fix: use package.searchpath to find libivyrs Now we are useing the package.searchpath to find the libivyrs.so or libivyrs.dylib. This is so it will load the correct library or the OS you are on. This fixes the issues with loading the library on macOS. Ref: #57 --- lua/ivy/libivy.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lua/ivy/libivy.lua b/lua/ivy/libivy.lua index c3ac126..f9f8857 100644 --- a/lua/ivy/libivy.lua +++ b/lua/ivy/libivy.lua @@ -1,6 +1,7 @@ local library_path = (function() - local dirname = string.sub(debug.getinfo(1).source, 2, #"/fzf_lib.lua" * -1) - return dirname .. "/../../target/release/libivyrs.so" + local root = string.sub(debug.getinfo(1).source, 2, #"/libivy.lua" * -1) + local release_path = root .. "../../target/release" + return package.searchpath("libivyrs", release_path .. "/?.so;" .. release_path .. "/?.dylib;") end)() local ffi = require "ffi"