mirror of
https://github.com/hexedtech/codemp-nvim.git
synced 2024-11-22 15:34:53 +01:00
alemi
3e9647ab39
it works well!!?! when it doesnt crash... but its also pretty clean maybe its our fault? could be worth investigating more lua ffi
56 lines
1.6 KiB
Lua
56 lines
1.6 KiB
Lua
local path = vim.fn.stdpath('data') .. '/codemp/'
|
|
if vim.fn.isdirectory(path) == 0 then
|
|
vim.fn.mkdir(path, 'p')
|
|
end
|
|
|
|
-- -- TODO not the best loader but a simple example? urls dont work
|
|
-- local host_os = vim.loop.os_uname().sysname
|
|
-- local ext = nil
|
|
-- if host_os == "Windows" then ext = ".dll"
|
|
-- elseif host_os == "Mac" then ext = ".dylib"
|
|
-- else ext = ".so"
|
|
-- end
|
|
--
|
|
-- local shasum = nil
|
|
--
|
|
-- if vim.fn.filereadable(path .. 'native' .. ext) == 1 then
|
|
-- shasum = vim.fn.system("sha256sum " .. path .. 'native' .. ext)
|
|
-- end
|
|
--
|
|
-- local last_sum = vim.fn.system("curl -s https://codemp.alemi.dev/lib/lua/latest/sum")
|
|
--
|
|
-- if last_sum ~= shasum then
|
|
-- vim.fn.system("curl -o " .. path .. 'native' .. ext .. "https://codemp.alemi.dev/lib/lua/latest")
|
|
-- end
|
|
|
|
local native = require('codemp.loader').load() -- make sure we can load the native library correctly, otherwise no point going forward
|
|
local state = require('codemp.state')
|
|
local rt = native.runtime_drive_forever() -- spawn thread to drive tokio runtime
|
|
-- native.logger(function (msg)
|
|
-- vim.schedule(function () print(msg) end)
|
|
-- end, true)
|
|
|
|
vim.api.nvim_create_autocmd(
|
|
{"ExitPre"},
|
|
{
|
|
callback = function (ev)
|
|
if state.client ~= nil then
|
|
print(" xx disconnecting codemp client")
|
|
native.close_client(state.client.id)
|
|
state.client = nil
|
|
end
|
|
end
|
|
}
|
|
)
|
|
|
|
require('codemp.command')
|
|
|
|
return {
|
|
native = native,
|
|
state = require('codemp.state'),
|
|
buffers = require('codemp.buffers'),
|
|
workspace = require('codemp.workspace'),
|
|
window = require('codemp.window'),
|
|
utils = require('codemp.utils'),
|
|
rt = rt,
|
|
}
|