mirror of
https://github.com/hexedtech/codemp-nvim.git
synced 2024-11-22 15:34:53 +01:00
fix: loader
This commit is contained in:
parent
d825a0d6fd
commit
40a8c49960
6 changed files with 43 additions and 17 deletions
|
@ -21,7 +21,7 @@ local function register_controller_handler(workspace, target, controller, handle
|
||||||
-- thread and requesting a new reference to the same controller from che global instance
|
-- thread and requesting a new reference to the same controller from che global instance
|
||||||
-- NOTE variables prefixed with underscore live in another Lua runtime
|
-- NOTE variables prefixed with underscore live in another Lua runtime
|
||||||
vim.loop.new_thread({}, function(_async, _workspace, _target, _delay)
|
vim.loop.new_thread({}, function(_async, _workspace, _target, _delay)
|
||||||
local _codemp = require("codemp.loader")() -- TODO maybe make a native.load() idk
|
local _codemp = require("codemp.loader").load() -- TODO maybe make a native.load() idk
|
||||||
local _ws = _codemp.get_workspace(_workspace)
|
local _ws = _codemp.get_workspace(_workspace)
|
||||||
local _controller = _target ~= nil and _ws:get_buffer(_target) or _ws.cursor
|
local _controller = _target ~= nil and _ws:get_buffer(_target) or _ws.cursor
|
||||||
while true do
|
while true do
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
local native = require('codemp.loader')()
|
local native = require('codemp.loader').load()
|
||||||
|
|
||||||
local utils = require('codemp.utils')
|
local utils = require('codemp.utils')
|
||||||
local async = require('codemp.async')
|
local async = require('codemp.async')
|
||||||
|
|
|
@ -1,11 +1,14 @@
|
||||||
local native = require('codemp.loader')()
|
local native = require('codemp.loader').load()
|
||||||
|
|
||||||
|
local workspace = nil
|
||||||
|
|
||||||
|
|
||||||
local function login(username, password, workspace)
|
local function login(username, password, ws)
|
||||||
native.login(username, password, workspace)
|
native.login(username, password, ws)
|
||||||
print(" ++ logged in as '" .. username .. "' on " .. workspace)
|
print(" ++ logged in as '" .. username .. "' on " .. ws)
|
||||||
end
|
end
|
||||||
|
|
||||||
return {
|
return {
|
||||||
login = login,
|
login = login,
|
||||||
|
workspace = workspace,
|
||||||
}
|
}
|
||||||
|
|
28
src/init.lua
28
src/init.lua
|
@ -1,11 +1,35 @@
|
||||||
local native = require('codemp.loader')() -- make sure we can load the native library correctly, otherwise no point going forward
|
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
|
||||||
|
|
||||||
-- TODO nvim docs say that we should stop all threads before exiting nvim
|
-- TODO nvim docs say that we should stop all threads before exiting nvim
|
||||||
-- but we like to live dangerously (:
|
-- but we like to live dangerously (:
|
||||||
vim.loop.new_thread({}, function()
|
vim.loop.new_thread({}, function()
|
||||||
vim.loop.sleep(500) -- sleep a bit leaving user config time to override logger opts
|
vim.loop.sleep(500) -- sleep a bit leaving user config time to override logger opts
|
||||||
local _codemp = require('codemp.loader')()
|
local _codemp = require('codemp.loader').load()
|
||||||
local logger = _codemp.setup_tracing()
|
local logger = _codemp.setup_tracing()
|
||||||
while true do
|
while true do
|
||||||
print(logger:recv())
|
print(logger:recv())
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
-- TODO check for platform? download it? check for updates?
|
return {
|
||||||
local function loader()
|
load = function ()
|
||||||
return require("libcodemp")
|
return require("codemp.native")
|
||||||
end
|
end
|
||||||
|
}
|
||||||
return loader
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
local native = require('codemp.loader')()
|
local native = require('codemp.loader').load()
|
||||||
|
|
||||||
local utils = require('codemp.utils')
|
local utils = require('codemp.utils')
|
||||||
local buffers = require('codemp.buffer')
|
local buffers = require('codemp.buffer')
|
||||||
|
@ -64,14 +64,14 @@ end
|
||||||
|
|
||||||
local function list_users(workspace)
|
local function list_users(workspace)
|
||||||
local workspace = native.get_workspace(workspace)
|
local workspace = native.get_workspace(workspace)
|
||||||
for _, buffer in ipairs(workspace.users) do
|
for _, buffer in pairs(workspace.users) do
|
||||||
print(" - " .. buffer)
|
print(" - " .. buffer)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function list_buffers(workspace)
|
local function list_buffers(workspace)
|
||||||
local workspace = native.get_workspace(workspace)
|
local workspace = native.get_workspace(workspace)
|
||||||
for _, buffer in ipairs(workspace.filetree) do
|
for _, buffer in pairs(workspace.filetree) do
|
||||||
print(" > " .. buffer)
|
print(" > " .. buffer)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue