You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Diffview takes over a whole tab, and it wouldn't make sense to replace any buffer in any of its windows.
This is nice:
require("stickybuf").setup({
get_auto_pin=function(bufnr)
-- pin if any of the windows of the current tab have a DiffviewFiles filetype-- (that's the filetype of the diffview sidebar, no switching buffers in that tab)for_, wininipairs(vim.api.nvim_tabpage_list_wins(0)) dolocalbuf=vim.api.nvim_win_get_buf(win)
localbuf_ft=vim.api.nvim_buf_get_option(buf, "ft")
ifbuf_ft=="DiffviewFiles" thenreturntrueendendreturnrequire("stickybuf").should_auto_pin(bufnr)
end
})
However I then hit this code from stickybuf:
-- If none exists, open the buffer in a vsplit from the first windowvim.fn.win_execute(vim.fn.win_getid(1), string.format("vertical rightbelow sbuffer %d", bufnr))
vim.cmd.wincmd({ count=2, args= { "w" } })
and a new window is opened in the diffview tab.
I would ideally like a way to dynamically say "in case X and Y, if no window is available, don't open a split window". I guess it would be possible to have that as a global setting (never open new windows), but maybe it'll be needed to make a dynamic decision for that. Maybe get_auto_pin could return instead of true/false, "pin_with_fallback" or "pin_without_fallback", or maybe it could be possible to pass a new function in the options, something like open_buffer_in_newsplit = function(bufnr) ... end...
The text was updated successfully, but these errors were encountered:
You can now pass handle_foreign_buffer = function() end to stickybuf.pin and that will do what you want. I also added the ability for get_auto_pin to return a table, which will then be passed in as options to stickybuf.pin. So you can return the table with that value from get_auto_pin
I was trying to set up stickybuf in my config for diffview https://github.com/sindrets/diffview.nvim
Diffview takes over a whole tab, and it wouldn't make sense to replace any buffer in any of its windows.
This is nice:
However I then hit this code from stickybuf:
and a new window is opened in the diffview tab.
I would ideally like a way to dynamically say "in case X and Y, if no window is available, don't open a split window". I guess it would be possible to have that as a global setting (never open new windows), but maybe it'll be needed to make a dynamic decision for that. Maybe
get_auto_pin
could return instead of true/false,"pin_with_fallback"
or"pin_without_fallback"
, or maybe it could be possible to pass a new function in the options, something likeopen_buffer_in_newsplit = function(bufnr) ... end
...The text was updated successfully, but these errors were encountered: