-
Notifications
You must be signed in to change notification settings - Fork 68
Open
Labels
PRs-welcomeI'd love to see a PR for thisI'd love to see a PR for thisenhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomers
Description
Similar Issues
- Before filing, I have searched for similar issues.
Description
When swapping buffers between windows where { move_cursor = true } it would be nice if the cursor position in each respective buffer is preserved/restored after the swap. As an example, I can restore the cursor position in the active buffer after the swap via the following.
local function swap(direction)
return function()
local cursor = vim.api.nvim_win_get_cursor(0)
require("smart-splits")['swap_buf_' .. direction]({ move_cursor = true })
vim.api.nvim_win_set_cursor(0, cursor)
end
end
vim.keymap.set('n', '<leader><leader>h', swap('left'))
vim.keymap.set('n', '<leader><leader>j', swap('down'))
vim.keymap.set('n', '<leader><leader>k', swap('up'))
vim.keymap.set('n', '<leader><leader>l', swap('right'))Though with this approach I cannot restore the cursor in the buffer that I am swapping with because getting direction-based window ids is internal to the plugin. An alternative to making this behavior the default would be to expose API functions that allow user code to query for window ids that are left/down/up/right to a given window id. The latter would also enable users to implement custom functionality and not require changes to the plugin itself.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
PRs-welcomeI'd love to see a PR for thisI'd love to see a PR for thisenhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomers