feat(git): open commits from gitlog in the same window

This commit is contained in:
2026-04-28 07:55:25 +02:00
parent 9ef5180a6a
commit 01c0f82e18
3 changed files with 28 additions and 12 deletions
+7 -2
View File
@@ -28,9 +28,9 @@ end
---@class ow.Git.NewScratchOpts
---@field name string?
---@field bufhidden ("hide"|"wipe")? defaults to "hide"
---@field split ("above"|"below"|"left"|"right")? defaults to splitbelow-aware horizontal
---@field split (false|"above"|"below"|"left"|"right")? defaults to splitbelow-aware horizontal. `false` places the buffer in the current window (drops a `'` mark first so the user can jump back).
---Open a split with a fresh non-modifiable scratch buffer. Default split
---Create a fresh non-modifiable scratch buffer and place it. Default split
---direction is horizontal, honouring `splitbelow`. Caller flips
---`modifiable`, fills the buffer, and sets `filetype` once content lands.
---@param opts ow.Git.NewScratchOpts?
@@ -47,6 +47,11 @@ function M.new_scratch(opts)
if opts.name then
pcall(vim.api.nvim_buf_set_name, buf, opts.name)
end
if opts.split == false then
vim.cmd.normal({ "m'", bang = true })
vim.api.nvim_set_current_buf(buf)
return buf, vim.api.nvim_get_current_win()
end
local split = opts.split or (vim.o.splitbelow and "below" or "above")
local win = vim.api.nvim_open_win(buf, true, { split = split })
return buf, win