ghillb / cybu.nvim

Neovim plugin that offers context when cycling buffers in the form of a customizable notification window.
MIT License
308 stars 5 forks source link

Disable popup while switching #17

Closed lucasrabiec closed 1 year ago

lucasrabiec commented 1 year ago

I am struggling with customization. I want to switch between history without a popup window. Is it possible? How I can achieve this?

PS For what is the auto mode?

ghillb commented 1 year ago

Hi! You can bind :bnext & :bprevious to switch between buffers. To go straight to the last used buffer, you can press/remap <c-6> or :b#, you don't need cybu for that.

vim.keymap.set("n", "L", ":bnext<cr>")
vim.keymap.set("n", "H", ":bprevious<cr>")
vim.keymap.set("n", "K", ":b#<cr>")

The show_on_autocmd config key lets you define an event (e.g. BufEnter)that triggers the cybu popup. The view for this mode can be changed by adapting the behavior.mode.auto.view key

behavior = {
  mode = {
    auto = {
      view = "rolling", -- paging, rolling
    },
  },
  show_on_autocmd = "BufEnter",
}
lucasrabiec commented 1 year ago

The show_on_autocmd config key lets you define an event (e.g. BufEnter)that triggers the cybu popup. The view for this mode can be changed by adapting the behavior.mode.auto.view key

Oh okay, I get it, TY

Hi! You can bind :bnext & :bprevious to switch between buffers. To go straight to the last used buffer, you can press/remap or :b#, you don't need cybu for that.

AFAIK :bnext and :bprevious switch buffers by their id not in the order that I opened them. I thought CybuLastusedPrev/Next do that but I noticed it also reorders buffers when I open the Next one.

E.g. with CybuLastusedPrev/Next I opened 1.txt -> 2.txt -> 3.txt -> 4.txt. Number 4 is currently open then I hit Prev and it opens 1 (not 3?), then Prev and it opens 2, Prev and 3. When I hit Next then 2.txt is opened, and when I hit Next again, 3 is opened. Hitting Next at this point switches between 2 and 3. I don't know if it is desirable or bugged but for me, it doesn't make sense. Maybe I'm missing something.

I'm looking for something more like switching the tabs in a web browser that doesn't reorder them but stack buffers and goes forward and backward that stack (ideally per window). Bufferline.nvim does that but I don't like to have a tab line visible at all and AFAIK Bufferline needs to have it visible to work.

ghillb commented 1 year ago

I'm looking for something more like switching the tabs in a web browser that doesn't reorder them but stack buffers and goes forward and backward that stack.

Currently, this only works, if you set behavior.last_used.switch = "on_close". Then the last used list is only changed once when the switch to the selected buffer happens on close of the window.

There are two things that could be improved here for the plugin

  1. Make it function with behavior.last_used.switch = "immediate" without changing the last used list
    • A new mechanism to keep track of the buffer history is needed (let's call it cybu stack) / this cybu stack only updates when the popup closes / or the timer (see 2.) expires
  2. Make it possible to use CybuLastusedPrev/Next without popup, so that the last used buffer switching through the cybu stack is possible without the context window. For this to properly work, there needs to be a timer, that starts after the last buffer switch with CybuLastusedPrev/Next and after its expiration the cybu stack updates

The non-trivial part is to make the cybu stack mechanism work correctly. I will take a look at it as soon as I have time.

(PRs are always welcome)

lucasrabiec commented 1 year ago

Is it possible to make something different than 1 and 2? Switching between the previous and next in history (recently opened) without any updates or reorders and also without showing the popup? Just the same behavior as in Chrome for example (ctrl+tab - next, ctrl+shift+tab - previous). No popups, no reorders, no updates of last used, just jumping +1/-1.

1) 1 | 2 |3| 4 - where 3 is currently opened 2) Next -> goes to 4 3) Prev -> goes to 3 4) Prev -> goes to 2 5) I am closing 2 6) New order: 1 |2| 3 - so the 3rd is the new 2 and 4th is the new 3 7) Next -> goes to 3 8) I am opening a file (added after 3rd) 9) 1 | 2 | 3 |4

New files could always be added to the end

I'm new in Neovim and Lua so I don't know if it is possible and how much effort it will take but something like this would be great.

lucasrabiec commented 1 year ago

I found what I need: https://github.com/ton/vim-bufsurf. Thank you for your time. I think we can close this issue.