Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lua/neo-zoom/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ function M.setup(opts)
M.callbacks = opts.callbacks or {}
if type(M.callbacks) ~= 'table' then M.callbacks = {} end
U.table_add_values(M.callbacks, require('neo-zoom.presets.callbacks'))
M.close_callbacks = opts.close_callbacks or {}
if type(M.close_callbacks) ~= 'table' then M.close_callbacks = {} end


update_internals()
Expand Down Expand Up @@ -155,6 +157,7 @@ function M.neo_zoom(opts)
end

M.zoom_book[win_zoom or 0] = nil
U.run_callbacks(M.close_callbacks)
return
end

Expand Down
2 changes: 2 additions & 0 deletions lua/neo-zoom/presets/callbacks.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ local M = {}

function M.fix_narrow_zoom_in_window()
-- see issue #73.
-- skip in terminal mode, as normal-mode commands can't be used there.
if vim.fn.mode() == 't' then return end
local offset_right = 5
local rhs = vim.api.nvim_win_get_width(0) - vim.fn.wincol() - offset_right
vim.cmd('normal! z' .. tostring(rhs) .. 'h')
Expand Down
8 changes: 8 additions & 0 deletions lua/neo-zoom/utils/autocmd.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,15 @@ local function detect_colon_q()
local view = vim.fn.winsaveview()
local buf_zoom = vim.api.nvim_get_current_buf()
local win_enter = require('neo-zoom').zoom_book[vim.api.nvim_get_current_win()]
vim.api.nvim_exec_autocmds('User', {
pattern = 'NeoZoomClosed',
data = {
original_win = win_enter,
}
})

require('neo-zoom').zoom_book[vim.api.nvim_get_current_win()] = nil
require('neo-zoom.utils').run_callbacks(require('neo-zoom').close_callbacks)
-- this will be triggered right after `WinClosed`.
vim.api.nvim_create_autocmd({ 'WinEnter' }, {
group = 'NeoZoom.lua',
Expand Down