2024-09-05 05:16:18 +02:00
|
|
|
local plugin_dir = vim.fn.fnamemodify(debug.getinfo(1, "S").source:sub(2), ":p:h") -- got this from https://lazy.folke.io/developers#building
|
2024-09-05 05:27:00 +02:00
|
|
|
|
2024-09-10 16:07:08 +02:00
|
|
|
-- TODO not the best loader but a simple example? urls dont work
|
|
|
|
local os_uname = vim.loop.os_uname()
|
|
|
|
|
|
|
|
local arch = os_uname.machine
|
|
|
|
|
|
|
|
local platform = string.lower(os_uname.sysname)
|
|
|
|
if platform == "mac" then platform = "darwin" end
|
|
|
|
|
|
|
|
local ext = os_uname.sysname
|
|
|
|
if os_uname.sysname == "Windows" then ext = ".dll"
|
|
|
|
elseif os_uname.sysname == "Mac" then ext = ".dylib"
|
|
|
|
else ext = ".so"
|
|
|
|
end
|
|
|
|
|
|
|
|
-- -- TODO compare checksum before redownloading
|
2024-09-05 05:38:45 +02:00
|
|
|
-- if vim.fn.filereadable(path .. 'native' .. ext) == 1 then
|
|
|
|
-- shasum = vim.fn.system("sha256sum " .. path .. 'native' .. ext)
|
|
|
|
-- end
|
2024-09-10 16:07:08 +02:00
|
|
|
|
|
|
|
local native_path = plugin_dir .. "/lua/codemp/native." .. ext
|
|
|
|
local download_url_native = string.format("https://code.mp/releases/lua/codemp-lua-%s-%s.%s", arch, platform, ext)
|
2024-09-05 05:45:46 +02:00
|
|
|
print("downloading codemp native lua extension...")
|
2024-09-06 03:26:30 +02:00
|
|
|
vim.system({"curl", "-s", "-o", native_path, download_url_native }):wait() -- TODO can we run this asynchronously?
|