fix
This commit is contained in:
parent
62a5fd5014
commit
611ed89f33
|
@ -29,20 +29,20 @@ local function is_shared_session()
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Create an autocommand group for shared session warning
|
||||||
|
local shared_session_group = vim.api.nvim_create_augroup("SharedSessionWarning", { clear = true })
|
||||||
|
|
||||||
|
|
||||||
-- Override quit commands for shared sessions
|
-- Override quit commands for shared sessions
|
||||||
vim.api.nvim_create_autocmd('VimLeavePre', {
|
vim.api.nvim_create_autocmd('VimLeavePre', {
|
||||||
group = augroup 'shared_session_warning',
|
group = shared_session_group,
|
||||||
callback = function()
|
callback = function()
|
||||||
if is_shared_session() then
|
if is_shared_session() then
|
||||||
vim.ui.input({
|
local response = vim.fn.input("⚠️ Closing shared nvim session! Confirm with y/Y: ")
|
||||||
prompt = '⚠️ Are you sure you want to close a shared session? ',
|
if response:lower() ~= "y" then
|
||||||
}, function(input)
|
-- Cancel the quit by throwing an error
|
||||||
if not input or input:lower() ~= 'y' then
|
error("Quit cancelled")
|
||||||
-- Cancel the quit
|
|
||||||
vim.fn.feedkeys(vim.api.nvim_replace_termcodes('<C-c>', true, false, true), 'n', false)
|
|
||||||
error 'Quit cancelled'
|
|
||||||
end
|
end
|
||||||
end)
|
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue