diff --git a/lua/codemp/command.lua b/lua/codemp/command.lua index 8546e68..d8625d3 100644 --- a/lua/codemp/command.lua +++ b/lua/codemp/command.lua @@ -80,6 +80,10 @@ local connected_actions = { end, disconnect = function() + if CODEMP.workspace ~= nil then + print(" xx leaving workspace " .. CODEMP.workspace.name) + workspace.leave() + end print(" xx disconnecting client " .. CODEMP.client.id) CODEMP.client = nil -- should drop and thus close everything collectgarbage("collect") -- make sure we drop diff --git a/lua/codemp/init.lua b/lua/codemp/init.lua index 44935dc..964fd4f 100644 --- a/lua/codemp/init.lua +++ b/lua/codemp/init.lua @@ -37,6 +37,10 @@ if CODEMP == nil then {"ExitPre"}, { callback = function (_ev) + if CODEMP.workspace ~= nil then + print(" xx leaving workspace " .. CODEMP.workspace.name) + require('codemp.workspace').leave() + end if CODEMP.client ~= nil then print(" xx disconnecting codemp client") CODEMP.client = nil -- drop reference so it gets garbage collected diff --git a/lua/codemp/neo-tree/commands.lua b/lua/codemp/neo-tree/commands.lua index 1d8f949..021f9d9 100644 --- a/lua/codemp/neo-tree/commands.lua +++ b/lua/codemp/neo-tree/commands.lua @@ -116,6 +116,7 @@ M.delete = function(state, path, extra) if selected.type == "title" then vim.ui.input({ prompt = "disconnect from server?" }, function(choice) if not choice or not vim.startswith(string.lower(choice), "y") then return end + if CODEMP.workspace ~= nil then ws_manager.leave() end CODEMP.client = nil collectgarbage("collect") -- to make sure we drop the reference and disconnect end)