Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: swap_buf doesnt work with splits of the same file #245

Open
1 task done
Ajaymamtora opened this issue Sep 24, 2024 · 4 comments
Open
1 task done

[Bug]: swap_buf doesnt work with splits of the same file #245

Ajaymamtora opened this issue Sep 24, 2024 · 4 comments
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers PRs-welcome I'd love to see a PR for this

Comments

@Ajaymamtora
Copy link

Similar Issues

  • Before filing, I have searched for similar issues.

Neovim Version

NVIM v0.10.1
Build type: Release
LuaJIT 2.1.1713484068
Run "nvim -V1 -v" for more info

Multiplexer Integration

I don't use one

Multiplexer Version

No response

Steps to Reproduce

  1. Create vertical split

  2. Adjust size of split

  3.       require("smart-splits").swap_buf_left() --or other dir
    
  4. Buffers dont swap.

Expected Behavior

They should swap

Actual Behavior

They dont swap

Minimal Configuration to Reproduce

modules["mrjones2014/smart-splits.nvim"] = {
  lazy = false,
  version = false,
  opts = {
    -- Ignored buffer types (only while resizing)
    ignored_buftypes = {
      "nofile",
      "quickfix",
      "prompt",
    },
    -- Ignored filetypes (only while resizing)
    ignored_filetypes = { "neo-tree" },
    -- the default number of lines/columns to resize by at a time
    default_amount = 3,
    -- Desired behavior when your cursor is at an edge and you
    -- are moving towards that same edge:
    -- 'wrap' => Wrap to opposite side
    -- 'split' => Create a new split in the desired direction
    -- 'stop' => Do nothing
    -- function => You handle the behavior yourself
    -- NOTE: If using a function, the function will be called with
    -- a context object with the following fields:
    -- {
    --    mux = {
    --      type:'tmux'|'wezterm'|'kitty'
    --      current_pane_id():number,
    --      is_in_session(): boolean
    --      current_pane_is_zoomed():boolean,
    --      -- following methods return a boolean to indicate success or failure
    --      current_pane_at_edge(direction:'left'|'right'|'up'|'down'):boolean
    --      next_pane(direction:'left'|'right'|'up'|'down'):boolean
    --      resize_pane(direction:'left'|'right'|'up'|'down'):boolean
    --      split_pane(direction:'left'|'right'|'up'|'down',size:number|nil):boolean
    --    },
    --    direction = 'left'|'right'|'up'|'down',
    --    split(), -- utility function to split current Neovim pane in the current direction
    --    wrap(), -- utility function to wrap to opposite Neovim pane
    -- }
    -- NOTE: `at_edge = 'wrap'` is not supported on Kitty terminal
    -- multiplexer, as there is no way to determine layout via the CLI
    at_edge = "wrap",
    -- when moving cursor between splits left or right,
    -- place the cursor on the same row of the *screen*
    -- regardless of line numbers. False by default.
    -- Can be overridden via function parameter, see Usage.
    move_cursor_same_row = false,
    -- whether the cursor should follow the buffer when swapping
    -- buffers by default; it can also be controlled by passing
    -- `{ move_cursor = true }` or `{ move_cursor = false }`
    -- when calling the Lua function.
    cursor_follows_swapped_bufs = false,
    -- resize mode options
    resize_mode = {
      -- key to exit persistent resize mode
      quit_key = "<ESC>",
      -- keys to use for moving in resize mode
      -- in order of left, down, up' right
      resize_keys = { "h", "j", "k", "l" },
      -- set to true to silence the notifications
      -- when entering/exiting persistent resize mode
      silent = false,
      -- must be functions, they will be executed when
      -- entering or exiting the resize mode
      hooks = {
        on_enter = nil,
        on_leave = nil,
      },
    },
    -- ignore these autocmd events (via :h eventignore) while processing
    -- smart-splits.nvim computations, which involve visiting different
    -- buffers and windows. These events will be ignored during processing,
    -- and un-ignored on completed. This only applies to resize events,
    -- not cursor movement events.
    ignored_events = {
      "BufEnter",
      "WinEnter",
    },
    -- enable or disable a multiplexer integration;
    -- automatically determined, unless explicitly disabled or set,
    -- by checking the $TERM_PROGRAM environment variable,
    -- and the $KITTY_LISTEN_ON environment variable for Kitty
    multiplexer_integration = "WezTerm",
    -- disable multiplexer navigation if current multiplexer pane is zoomed
    -- this functionality is only supported on tmux and Wezterm due to kitty
    -- not having a way to check if a pane is zoomed
    disable_multiplexer_nav_when_zoomed = true,
    -- Supply a Kitty remote control password if needed,
    -- or you can also set vim.g.smart_splits_kitty_password
    -- see https://sw.kovidgoyal.net/kitty/conf/#opt-kitty.remote_control_password
    kitty_password = nil,
    -- default logging level, one of: 'trace'|'debug'|'info'|'warn'|'error'|'fatal'
    log_level = "info",
  },
}

Additional Details and/or Screenshots

No response

@Ajaymamtora Ajaymamtora added the bug Something isn't working label Sep 24, 2024
@mrjones2014
Copy link
Owner

So, what is the expected behavior exactly when it's the same buffer in both windows? Just moving the cursor position?

Technically it does work; this function swaps the buffers between two windows, so if it's the same buffer, it would be kind of expected that nothing would happen.

@mrjones2014
Copy link
Owner

Also, please use the minimal config template. I should be able to download the config and run it with nvim -u ./minimal.lua. The minimal config you posted in the issue will not work.

@Ajaymamtora
Copy link
Author

So, what is the expected behavior exactly when it's the same buffer in both windows? Just moving the cursor position?

Technically it does work; this function swaps the buffers between two windows, so if it's the same buffer, it would be kind of expected that nothing would happen.

I would expect it to swap the actual 2 instances, so the position in the buffer/folds etc swaps.

@Ajaymamtora
Copy link
Author

Also, please use the minimal config template. I should be able to download the config and run it with nvim -u ./minimal.lua. The minimal config you posted in the issue will not work.

Will do

@mrjones2014 mrjones2014 added enhancement New feature or request good first issue Good for newcomers PRs-welcome I'd love to see a PR for this and removed bug Something isn't working labels Sep 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers PRs-welcome I'd love to see a PR for this
Projects
None yet
Development

No branches or pull requests

2 participants