feat: delete command in neo-tree

This commit is contained in:
əlemi 2024-09-07 01:31:04 +02:00
parent a98c216a8f
commit 7fd36cf95c
Signed by: alemi
GPG key ID: A4895B84D311642C

View file

@ -72,6 +72,23 @@ M.move = function(state, path, extra)
error("only buffers can be moved to current file") error("only buffers can be moved to current file")
end end
M.delete = function(state, path, extra)
local selected = state.tree:get_node()
if selected.type == "buffer" then
if session.workspace == nil then error("join a workspace first") end
session.workspace:delete_buffer(selected.name):await()
print("deleted buffer " .. selected.name)
manager.refresh("codemp")
elseif selected.type == "workspace" then
if session.client == nil then error("connect to server first") end
session.client:delete_workspace(selected.name):await()
print("deleted workspace " .. selected.name)
manager.refresh("codemp")
else
print("/!\\ can only delete buffers and workspaces")
end
end
M.add = function(_state) M.add = function(_state)
if session.client == nil then if session.client == nil then
vim.ui.input({ prompt = "server address" }, function(input) vim.ui.input({ prompt = "server address" }, function(input)
@ -91,6 +108,7 @@ M.add = function(_state)
manager.refresh("codemp") manager.refresh("codemp")
end) end)
end end
manager.refresh("codemp")
end end
cc._add_common_commands(M) cc._add_common_commands(M)