feat(git): open commits from gitlog in the same window
This commit is contained in:
+7
-2
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user