From e7dc51c79c985695214491d49b05eebf8f9465b9 Mon Sep 17 00:00:00 2001
From: alemi <me@alemi.dev>
Date: Sat, 15 Feb 2025 12:16:50 +0100
Subject: [PATCH] fix: print error when failed loading

also move back loading out of setup
---
 lua/codemp/init.lua   | 16 ++++++++--------
 lua/codemp/loader.lua |  1 +
 2 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/lua/codemp/init.lua b/lua/codemp/init.lua
index 0852bd7..bb2bba2 100644
--- a/lua/codemp/init.lua
+++ b/lua/codemp/init.lua
@@ -28,14 +28,6 @@ if CODEMP == nil then
 			password = "",
 		},
 		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)
 			-- register logger
 			CODEMP.native.setup_tracing(CODEMP.config.debug_file or print, CODEMP.config.debug)
@@ -78,4 +70,12 @@ if CODEMP == nil then
 	}
 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
diff --git a/lua/codemp/loader.lua b/lua/codemp/loader.lua
index 75de3cf..c6041c1 100644
--- a/lua/codemp/loader.lua
+++ b/lua/codemp/loader.lua
@@ -4,6 +4,7 @@
 local function load()
 	local ok, native = pcall(require, "codemp.native")
 	if ok then return native end
+	print(native)
 	return nil
 end