feat(buffer): open as bottom-drawer split like fugitive (#23)
* feat(buffer): open as bottom-drawer split like fugitive Problem: :Pending replaced the current buffer, making it impossible to view tasks alongside the file being edited. No way to close the drawer without :q or switching buffers manually. Solution: open the task buffer in a botright horizontal split instead of replacing the current buffer. Track the drawer window ID so re-opening focuses it rather than creating a second split. Set winfixheight so the drawer keeps its height when other windows open or close. Add q/<Esc> mappings to close the drawer, and a WinClosed autocmd to clear the tracked window ID when the user closes it manually. Add drawer_height config option (default 15). * fix(buffer): default to natural split height like fugitive Problem: hardcoded drawer_height=15 was too small and diverged from fugitive's model. Fugitive issues a plain botright split and lets Vim's own split rules (equalalways, winheight) divide the available space. Solution: remove the default height so the split sizes naturally. Only call nvim_win_set_height when the user sets drawer_height to a positive value, preserving the opt-in customization path.
This commit is contained in:
parent
e04440bb3d
commit
d1be0985b6
3 changed files with 49 additions and 14 deletions
|
|
@ -38,11 +38,25 @@ function M._setup_autocmds(bufnr)
|
|||
end
|
||||
end,
|
||||
})
|
||||
vim.api.nvim_create_autocmd('WinClosed', {
|
||||
group = group,
|
||||
callback = function(ev)
|
||||
if tonumber(ev.match) == buffer.winid() then
|
||||
buffer.clear_winid()
|
||||
end
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
---@param bufnr integer
|
||||
function M._setup_buf_mappings(bufnr)
|
||||
local opts = { buffer = bufnr, silent = true }
|
||||
vim.keymap.set('n', 'q', function()
|
||||
buffer.close()
|
||||
end, opts)
|
||||
vim.keymap.set('n', '<Esc>', function()
|
||||
buffer.close()
|
||||
end, opts)
|
||||
vim.keymap.set('n', '<CR>', function()
|
||||
M.toggle_complete()
|
||||
end, opts)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue