fix: print error when failed loading

also move back loading out of setup
This commit is contained in:
əlemi 2025-02-15 12:16:50 +01:00
parent f031ee8d5b
commit e7dc51c79c
Signed by: alemi
GPG key ID: A4895B84D311642C
2 changed files with 9 additions and 8 deletions

View file

@ -28,14 +28,6 @@ if CODEMP == nil then
password = "", password = "",
}, },
setup = function (opts) setup = function (opts)
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")
return CODEMP
end
end
CODEMP.config = vim.tbl_extend('force', CODEMP.config, opts) CODEMP.config = vim.tbl_extend('force', CODEMP.config, opts)
-- register logger -- register logger
CODEMP.native.setup_tracing(CODEMP.config.debug_file or print, CODEMP.config.debug) CODEMP.native.setup_tracing(CODEMP.config.debug_file or print, CODEMP.config.debug)
@ -78,4 +70,12 @@ if CODEMP == nil then
} }
end 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")
return CODEMP
end
end
return CODEMP return CODEMP

View file

@ -4,6 +4,7 @@
local function load() local function load()
local ok, native = pcall(require, "codemp.native") local ok, native = pcall(require, "codemp.native")
if ok then return native end if ok then return native end
print(native)
return nil return nil
end end