Closed alesandar closed 1 year ago
Noticed another weird behavior when navigating between splits.
Calling move_cursor_*
(when a floating window is focused) does not move the cursor in the right direction.
Open Neovim, create a new split, focus the previous one, create a floating window and try to navigate in any direction.
:botright vsplit
:wincmd h
:lua vim.api.nvim_open_win(0, true, { relative = 'editor', width = 10, height = 10, col = 0, row = 0, border = 'solid' })
:lua lua require('smart-splits').move_cursor_right()
Hm yeah, I think the behavior would be weird with floating windows.
I would probably say that moving between multiple floating windows is not supported, as wincmd h/j/k/l
will probably have inconsistent behavior in groups of floating windows, which this plugin relies on.
I think resizing floating windows would just be unsupported too
@mrjones2014, I have tested the changes from https://github.com/mrjones2014/smart-splits.nvim/pull/123.
It appears that move/resize capabilities are completely disabled if a floating window is focused. That behavior might be considered disruptive by some users, since one should always close the floating window first (before switching between splits).
Would you mind if I try to implement a different solution before merging #123? I was working on a few other improvements, so I have become familiar with most of the source code.
Here is my current solution: https://github.com/mrjones2014/smart-splits.nvim/commit/ecea65d8f029978d92e29f5fa83f6774f31249aa.
Basically, if the current window is floating, the cursor will be moved back to the most recently accessed window.
That fallback works quite well, because WinLeave
auto-commands of other plugins will get triggered.
For example, telescope.nvim and oil.nvim will automatically close their corresponding floating windows when they lose focus.
Alternatively, if the previous window is also floating - the method will be aborted, just as you initially did.
I like your solution. Can you submit a PR? I will test + approve yours, and close mine.
Similar Issues
Neovim Version
NVIM v0.10.0-dev-539+g72a6643b13 Build type: RelWithDebInfo LuaJIT 2.1.0-beta3
Multiplexer Integration
tmux
Multiplexer Version
tmux 3.3a
Steps to Reproduce
0) Open Neovim and enter command-line mode by pressing
:
1) Open a floating window or manually create one by issuing the following one-liner:2) Press any of your resize key-mapings (
Alt-{h,j,k,l}
) or call one of the resize functions manually:Expected Behavior
Floating windows should be ignored by resize.
I can not think of anything else that could be done, since many plugins (e.g. telescope.nvim) use multiple floating windows.
Actual Behavior
Floating windows are resized.
Minimal Configuration to Reproduce
Additional Details and/or Screenshots
Here's an if-statement that can be used to check if the current window is floating.