Lets pretend I have a Vim session with buffers that look like this:
+-------------+--------------+
| | |
| | |
| | |
| | |
| | |
| 1 | 2 |
| | |
| | |
| | |
| | |
| | |
+-------------+--------------+
Is there a way to query which buffer is to the right of buffer #1?
Ideally, I'd want something like this (Obviously this isn't Vimscript but I hope it gives you the idea):
get_neighboring_buffers(current_buffer=1, direction="right")
# Result: [2]
And then consider this window layout
+-------------+--------------+
| | |
| | |
| | 2 |
| | |
| | |
| 1 +--------------+
| | |
| | |
| | 3 |
| | |
| | |
+-------------+--------------+
In this case, the same function might return more than one buffer:
get_neighboring_buffers(current_buffer=1, direction="right")
# Result: [2, 3]
Alternatively, is there a way to check which buffer is more "on-top" of another?
get_topmost_buffer([2, 3])
# Result: 2
I'm trying to find the nearest-right buffer for a script I'm writing but am having trouble finding resources about this online.
Ideally, the solution should be able to handle the 3-buffer setup I showed but if it only works with the first example (the vertical split) then that's fine.
Any help would be appreciated.