From 556dcf761d05272e2513c83b63ac3201daccc43c Mon Sep 17 00:00:00 2001 From: Ade Attwood Date: Wed, 28 Dec 2022 14:49:03 +0000 Subject: [PATCH] fix: wrap ffi.load in pcall and give a better error message Now if libivyrs is not found you get a better message that points the user to the docs on compiling to try and help them resolve the issue. Ref: #35 --- lua/ivy/libivy.lua | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lua/ivy/libivy.lua b/lua/ivy/libivy.lua index f1267f5..c3ac126 100644 --- a/lua/ivy/libivy.lua +++ b/lua/ivy/libivy.lua @@ -4,7 +4,15 @@ local library_path = (function() end)() local ffi = require "ffi" -local ivy_c = ffi.load(library_path) +local ok, ivy_c = pcall(ffi.load, library_path) +if not ok then + vim.api.nvim_err_writeln( + "libivyrs.so not found! Please ensure you have complied the shared library." + .. " For more info refer to the documentation, https://github.com/AdeAttwood/ivy.nvim#compiling" + ) + + return +end ffi.cdef [[ void ivy_init(const char*);