mirror of
https://github.com/hexedtech/codemp-nvim.git
synced 2024-12-23 13:54:54 +01:00
fix: replace native library after quitting
This commit is contained in:
parent
485f2f941f
commit
b3bc67cd38
1 changed files with 12 additions and 2 deletions
14
build.lua
14
build.lua
|
@ -1,6 +1,5 @@
|
|||
local plugin_dir = vim.fn.fnamemodify(debug.getinfo(1, "S").source:sub(2), ":p:h") -- got this from https://lazy.folke.io/developers#building
|
||||
|
||||
-- TODO not the best loader but a simple example? urls dont work
|
||||
local os_uname = vim.loop.os_uname()
|
||||
|
||||
local arch = os_uname.machine
|
||||
|
@ -19,7 +18,18 @@ end
|
|||
-- shasum = vim.fn.system("sha256sum " .. path .. 'native' .. ext)
|
||||
-- end
|
||||
|
||||
local native_path = plugin_dir .. "/lua/codemp/native." .. ext
|
||||
local native_path = plugin_dir .. "/lua/codemp/new-native." .. ext
|
||||
local replace_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)
|
||||
print("downloading codemp native lua extension...")
|
||||
vim.system({"curl", "-s", "-o", native_path, download_url_native }):wait() -- TODO can we run this asynchronously?
|
||||
print("downloaded! exit nvim to reload library")
|
||||
|
||||
vim.api.nvim_create_autocmd(
|
||||
{"ExitPre"},
|
||||
{
|
||||
callback = function (_ev)
|
||||
vim.system({"sleep", "1", ";", "mv", native_path, replace_native_path}, { detach = true })
|
||||
end
|
||||
}
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue