rmagatti / goto-preview

A small Neovim plugin for previewing definitions using floating windows.
Apache License 2.0
779 stars 27 forks source link

[FEATURE] Closing `n+1` preview should move the focus to the `n` preview #77

Closed D00mch closed 5 months ago

D00mch commented 1 year ago

Describe the solution you'd like If I open previews a,b, and c, closing c should put my focus on b; closing b — on a.

Describe alternatives you've considered I have a function that I dovim.keymap.set with the local buffer inside the post_open_hook:

local function close_and_move_focus_on_prev()
  local prev_win = vim.fn.winnr()
  vim.cmd("wincmd p")
  return vim.cmd((prev_win .. "wincmd q"))
end

Additional context On the gif below I do:

  1. Show that I commented my buffer keymap.
  2. Open project and demonstrate, that after closing second preview I didn't go to the first one;
  3. Reopen config and uncomment my close_and_move_focus_on_prev function;
  4. Open project again and demonstrate that the problem is fixed.

(my config is in fennel).

demo

rmagatti commented 1 year ago

Hey 👋 that's weird. The order seems to be kept correctly for me here.

2022-12-08 11 15 04

D00mch commented 1 year ago

I close windows with mapping that does :q<Cr>. Don't know what may cause this behavior. Lets maybe wait for a while if anyone has the same problem.

rmagatti commented 1 year ago

I have the same exact mapping <leader>q :q<CR> so that shouldn't be the cause.

spocke commented 1 year ago

I have the same issue but I need to go three levels deep.

Tebro commented 5 months ago

Same issue here, if using <C-w>c it doesn't go back at all, if you chain three deep then :q will only go back once. I guess there is a variable last that gets updated instead of a stack?