From 2abe23e4933c5b0d7d0cc4b3e7f6d61eb5616b73 Mon Sep 17 00:00:00 2001 From: alemi Date: Sat, 14 Sep 2024 23:57:47 +0200 Subject: [PATCH] fix: first time load should not break installation --- lua/codemp/init.lua | 3 +++ lua/codemp/loader.lua | 7 ++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lua/codemp/init.lua b/lua/codemp/init.lua index 518eb33..9800855 100644 --- a/lua/codemp/init.lua +++ b/lua/codemp/init.lua @@ -18,6 +18,9 @@ end if CODEMP.native == nil then CODEMP.native = require('codemp.loader').load() -- make sure we can load the native library correctly, otherwise no point going forward + if CODEMP.native == nil then + print(" !! could not load native bindings, try reloading") + end --CODEMP.native.logger(function (msg) -- vim.schedule(function () print(msg) end) --end, true) diff --git a/lua/codemp/loader.lua b/lua/codemp/loader.lua index 6619a8f..75de3cf 100644 --- a/lua/codemp/loader.lua +++ b/lua/codemp/loader.lua @@ -1,9 +1,10 @@ ---@module 'annotations' ----@return Codemp +---@return Codemp? local function load() - local native, _ = require("codemp.native") - return native + local ok, native = pcall(require, "codemp.native") + if ok then return native end + return nil end return {