fix: setup just changes config

so its not really needed
This commit is contained in:
əlemi 2024-09-13 23:46:59 +02:00
parent 51d65eab3d
commit 8a12b109ff
Signed by: alemi
GPG key ID: A4895B84D311642C

View file

@ -12,51 +12,49 @@ if CODEMP == nil then
}, },
setup = function (opts) setup = function (opts)
CODEMP.config = vim.tbl_extend('force', CODEMP.config, opts) CODEMP.config = vim.tbl_extend('force', CODEMP.config, opts)
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
--CODEMP.native.logger(function (msg)
-- vim.schedule(function () print(msg) end)
--end, true)
end
if CODEMP.session == nil then
CODEMP.session = require('codemp.session')
end
if CODEMP.rt == nil then
CODEMP.rt = CODEMP.native.spawn_runtime_driver() -- spawn thread to drive tokio runtime
vim.api.nvim_create_autocmd(
{"ExitPre"},
{
callback = function (_ev)
if CODEMP.session.client ~= nil then
print(" xx disconnecting codemp client")
CODEMP.session.client = nil
end
CODEMP.rt:stop()
end
}
)
end
if CODEMP.timer == nil then
CODEMP.timer = vim.loop.new_timer()
CODEMP.timer:start(CODEMP.config.timer_interval, CODEMP.config.timer_interval, function()
while true do
local cb = CODEMP.native.poll_callback()
if cb == nil then break end
cb()
end
end)
require('codemp.command') -- not really related but should only happen once
end
return CODEMP
end,
} }
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
--CODEMP.native.logger(function (msg)
-- vim.schedule(function () print(msg) end)
--end, true)
end
if CODEMP.session == nil then
CODEMP.session = require('codemp.session')
end
if CODEMP.rt == nil then
CODEMP.rt = CODEMP.native.spawn_runtime_driver() -- spawn thread to drive tokio runtime
vim.api.nvim_create_autocmd(
{"ExitPre"},
{
callback = function (_ev)
if CODEMP.session.client ~= nil then
print(" xx disconnecting codemp client")
CODEMP.session.client = nil
end
CODEMP.rt:stop()
end
}
)
end
if CODEMP.timer == nil then
CODEMP.timer = vim.loop.new_timer()
CODEMP.timer:start(CODEMP.config.timer_interval, CODEMP.config.timer_interval, function()
while true do
local cb = CODEMP.native.poll_callback()
if cb == nil then break end
cb()
end
end)
require('codemp.command') -- not really related but should only happen once
end
return CODEMP return CODEMP