mirror of
https://github.com/hexedtech/codemp-nvim.git
synced 2024-11-22 07:24:52 +01:00
feat: commands to leave, delete, detach
This commit is contained in:
parent
44d9f9766b
commit
72661a2eec
2 changed files with 28 additions and 2 deletions
|
@ -11,6 +11,11 @@ local function create(name, content)
|
|||
print(" ++ created buffer '" .. name .. "' on " .. state.workspace)
|
||||
end
|
||||
|
||||
local function delete(name)
|
||||
state.client:get_workspace(state.workspace):delete_buffer(name)
|
||||
print(" -- deleted buffer " .. name)
|
||||
end
|
||||
|
||||
local function attach(name, force)
|
||||
local buffer = nil
|
||||
if force then
|
||||
|
@ -23,7 +28,7 @@ local function attach(name, force)
|
|||
vim.api.nvim_buf_set_name(buffer, "codemp::" .. name)
|
||||
vim.api.nvim_set_current_buf(buffer)
|
||||
end
|
||||
local controller = state.client:get_workspace(state.workspace):attach_buffer(name)
|
||||
local controller = state.client:get_workspace(state.workspace):attach(name)
|
||||
|
||||
-- TODO map name to uuid
|
||||
|
||||
|
@ -70,7 +75,7 @@ local function detach(name)
|
|||
local buffer = buffer_id_map[name]
|
||||
id_buffer_map[buffer] = nil
|
||||
buffer_id_map[name] = nil
|
||||
state.client:get_workspace(state.workspace):disconnect_buffer(name)
|
||||
state.client:get_workspace(state.workspace):detach(name)
|
||||
vim.api.nvim_buf_delete(buffer, {})
|
||||
|
||||
print(" -- detached from buffer " .. name)
|
||||
|
@ -92,6 +97,7 @@ end
|
|||
|
||||
return {
|
||||
create = create,
|
||||
delete = delete,
|
||||
sync = sync,
|
||||
attach = attach,
|
||||
detach = detach,
|
||||
|
|
|
@ -37,6 +37,12 @@ local connected_actions = {
|
|||
workspace.join(ws)
|
||||
print(" >< joined workspace " .. ws)
|
||||
end,
|
||||
|
||||
disconnect = function()
|
||||
print(" xx disconnecting client " .. state.client.id)
|
||||
native.close_client(state.client.id)
|
||||
state.client = nil
|
||||
end,
|
||||
}
|
||||
|
||||
-- only available if state.workspace is not nil
|
||||
|
@ -46,6 +52,11 @@ local joined_actions = {
|
|||
buffers.create(path)
|
||||
end,
|
||||
|
||||
delete = function(path)
|
||||
if path == nil then error("missing buffer name") end
|
||||
buffers.delete(path)
|
||||
end,
|
||||
|
||||
buffers = function()
|
||||
workspace.open_buffer_tree()
|
||||
end,
|
||||
|
@ -59,6 +70,15 @@ local joined_actions = {
|
|||
buffers.attach(path, bang)
|
||||
end,
|
||||
|
||||
detach = function(path)
|
||||
if path == nil then error("missing buffer name") end
|
||||
buffers.detach(path)
|
||||
end,
|
||||
|
||||
leave = function(ws)
|
||||
if ws == nil then error("missing workspace to leave") end
|
||||
state.client:leave_workspace(ws)
|
||||
end,
|
||||
}
|
||||
|
||||
vim.api.nvim_create_user_command(
|
||||
|
|
Loading…
Reference in a new issue