### Setup smart-splits.nvim with Defaults Source: https://github.com/mrjones2014/smart-splits.nvim/blob/master/_autodocs/README.md Initialize the plugin with default configuration settings. This is the simplest way to get started. ```lua require('smart-splits').setup() ``` -------------------------------- ### Basic Setup and Key Bindings for Smart Splits Source: https://github.com/mrjones2014/smart-splits.nvim/blob/master/_autodocs/00-START-HERE.md Demonstrates the basic setup for the smart-splits.nvim plugin and how to bind keys for resizing and moving the cursor between splits. Ensure the plugin is installed before using these commands. ```lua -- Basic setup require('smart-splits').setup() -- Bind keys vim.keymap.set('n', '', require('smart-splits').resize_left) vim.keymap.set('n', '', require('smart-splits').move_cursor_left) ``` -------------------------------- ### Install smart-splits.nvim with Lazy.nvim Source: https://github.com/mrjones2014/smart-splits.nvim/blob/master/doc/smart-splits.nvim.txt Example of how to install the plugin using the Lazy.nvim package manager. Shows options for version specification and enabling Kitty multiplexer support. ```lua { 'mrjones2014/smart-splits.nvim' } -- or use a specific version, or a range of versions using lazy.nvim's version API { 'mrjones2014/smart-splits.nvim', version = '>=1.0.0' } -- to use Kitty multiplexer support, run the post install hook { 'mrjones2014/smart-splits.nvim', build = './kitty/install-kittens.bash' } ``` -------------------------------- ### Install smart-splits.nvim with Packer.nvim Source: https://github.com/mrjones2014/smart-splits.nvim/blob/master/doc/smart-splits.nvim.txt Example of how to install the plugin using the Packer.nvim package manager. Includes options for specifying a version or enabling Kitty multiplexer support. ```lua use('mrjones2014/smart-splits.nvim') -- or use a specific version use({ 'mrjones2014/smart-splits.nvim', tag = 'v1.0.0' }) -- to use Kitty multiplexer support, run the post install hook use({ 'mrjones2014/smart-splits.nvim', run = './kitty/install-kittens.bash' }) ``` -------------------------------- ### Complete Smart Splits Configuration Example Source: https://github.com/mrjones2014/smart-splits.nvim/blob/master/_autodocs/configuration.md A comprehensive example demonstrating all available configuration options for smart-splits.nvim. ```lua require('smart-splits').setup({ -- Window management ignored_buftypes = { 'nofile', 'quickfix', 'prompt', }, ignored_filetypes = { 'NvimTree', }, default_amount = 3, -- Edge behavior at_edge = 'wrap', -- or 'split', 'stop', or function float_win_behavior = 'previous', -- Cursor behavior move_cursor_same_row = false, cursor_follows_swapped_bufs = false, -- Resize options ignored_events = { 'BufEnter', 'WinEnter', }, -- Multiplexer integration multiplexer_integration = nil, -- auto-detect disable_multiplexer_nav_when_zoomed = true, wezterm_cli_path = 'wezterm', kitty_password = nil, zellij_move_focus_or_tab = false, -- Logging log_level = 'info', }) ``` -------------------------------- ### Configuration Setup Source: https://github.com/mrjones2014/smart-splits.nvim/blob/master/_autodocs/INDEX.md Function to initialize the plugin with custom configuration settings. ```lua setup(config) ``` -------------------------------- ### Install with Lazy.nvim Source: https://github.com/mrjones2014/smart-splits.nvim/blob/master/README.md Use this snippet to install the plugin with Lazy.nvim. Specify a version for stable releases or use the build hook for Kitty multiplexer support. ```lua { 'mrjones2014/smart-splits.nvim' } ``` ```lua -- or use a specific version, or a range of versions using lazy.nvim's version API { 'mrjones2014/smart-splits.nvim', version = '>=1.0.0' } ``` ```lua -- to use Kitty multiplexer support, run the post install hook { 'mrjones2014/smart-splits.nvim', build = './kitty/install-kittens.bash' } ``` -------------------------------- ### Smart Splits Setup with Custom at_edge Handler Source: https://github.com/mrjones2014/smart-splits.nvim/blob/master/_autodocs/types.md Example of setting up smart-splits with a custom 'at_edge' handler. This handler checks if a multiplexer is active and uses its API or the wrap function based on the context. ```lua require('smart-splits').setup({ at_edge = function(ctx) print('Attempting to move:', ctx.direction) if ctx.mux and ctx.mux.is_in_session() then ctx.mux.next_pane(ctx.direction) else ctx.wrap() end end }) ``` -------------------------------- ### Install with Packer.nvim Source: https://github.com/mrjones2014/smart-splits.nvim/blob/master/README.md Use this snippet to install the plugin with Packer.nvim. Specify a version tag for stable releases or include the run hook for Kitty multiplexer support. ```lua use('mrjones2014/smart-splits.nvim') ``` ```lua -- or use a specific version use({ 'mrjones2014/smart-splits.nvim', tag = 'v1.0.0' }) ``` ```lua -- to use Kitty multiplexer support, run the post install hook use({ 'mrjones2014/smart-splits.nvim', run = './kitty/install-kittens.bash' }) ``` -------------------------------- ### Initialize Smart Splits Source: https://github.com/mrjones2014/smart-splits.nvim/blob/master/_autodocs/configuration.md Call the setup function with your custom configuration object to initialize smart-splits. ```lua require('smart-splits').setup(config) ``` -------------------------------- ### Core Functions - Setup Source: https://github.com/mrjones2014/smart-splits.nvim/blob/master/_autodocs/README.md Sets up the smart-splits.nvim plugin with default or custom configuration. This function should be called once during Neovim initialization. ```APIDOC ## setup(opts) ### Description Initializes the smart-splits.nvim plugin. It can be configured with various options to customize its behavior. ### Method `require('smart-splits').setup(opts)` ### Parameters #### Options Table (`opts`) - `default_amount` (number) - Optional - The default amount to use for resize operations. - `at_edge` (string) - Optional - Defines behavior when resizing at the edge of the screen. Possible values: 'wrap', 'stop'. - `move_cursor_same_row` (boolean) - Optional - If true, moving the cursor will keep it on the same row if possible. ### Request Example ```lua -- Setup with defaults require('smart-splits').setup() -- Or with custom configuration require('smart-splits').setup({ default_amount = 3, at_edge = 'wrap', move_cursor_same_row = false, }) ``` ``` -------------------------------- ### Logging Example Source: https://github.com/mrjones2014/smart-splits.nvim/blob/master/_autodocs/types.md Demonstrates how to access and use the logger to record debug messages and open the log file. Ensure the logger is configured with an appropriate log level. ```lua local log = require('smart-splits.log') log.debug('Resizing window: %s by %d', 'left', 5) log.open_log_file() -- Show debug log ``` -------------------------------- ### Configure smart-splits.nvim with default settings Source: https://github.com/mrjones2014/smart-splits.nvim/blob/master/doc/smart-splits.nvim.txt Example of how to set up smart-splits.nvim with default configuration options. This includes ignored buffer types and filetypes, default resize amount, and behavior when at an edge. ```lua require('smart-splits').setup({ -- Ignored buffer types (only while resizing) ignored_buftypes = { 'nofile', 'quickfix', 'prompt', }, -- Ignored filetypes (only while resizing) ignored_filetypes = { 'NvimTree' }, -- 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'|'zellij' -- 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', ``` -------------------------------- ### Custom at_edge Function Example Source: https://github.com/mrjones2014/smart-splits.nvim/blob/master/_autodocs/api-reference/multiplexer-api.md This example demonstrates how to configure a custom `at_edge` function to either interact with the multiplexer if in a session or wrap to the opposite side. ```lua require('smart-splits').setup({ at_edge = function(ctx) if ctx.mux and ctx.mux.is_in_session() then -- Custom multiplexer behavior ctx.mux.next_pane(ctx.direction) else -- Default: wrap ctx.wrap() end end, }) ``` -------------------------------- ### Setup smart-splits.nvim Configuration Source: https://github.com/mrjones2014/smart-splits.nvim/blob/master/README.md Configure ignored buffer types and filetypes for resizing. Set the default amount for resizing and define behavior when the cursor is at an edge. ```lua require('smart-splits').setup({ -- Ignored buffer types (only while resizing) ignored_buftypes = { 'nofile', 'quickfix', 'prompt', }, -- Ignored filetypes (only while resizing) ignored_filetypes = { 'NvimTree' }, -- 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'|'zellij' -- current_pane_id():number, -- is_in_session(): boolean -- 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', -- Desired behavior when the current window is floating: -- 'previous' => Focus previous Vim window and perform action -- 'mux' => Always forward action to multiplexer float_win_behavior = 'previous', -- 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, -- 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. -- You can also set this value by setting `vim.g.smart_splits_multiplexer_integration` -- before the plugin is loaded (e.g. for lazy environments). multiplexer_integration = nil, -- disable multiplexer navigation if current multiplexer pane is zoomed -- NOTE: This does not work on Zellij as there is no way to determine the -- pane zoom state outside of the Zellij Plugin API, which does not apply here 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, -- In Zellij, set this to true if you would like to move to the next *tab* -- when the current pane is at the edge of the zellij tab/window zellij_move_focus_or_tab = false, -- default logging level, one of: 'trace'|'debug'|'info'|'warn'|'error'|'fatal' log_level = 'info', }) ``` -------------------------------- ### Setup smart-splits.nvim with Custom Configuration Source: https://github.com/mrjones2014/smart-splits.nvim/blob/master/_autodocs/README.md Configure the plugin with custom options to control split pane behavior. Options include default split amount, edge wrapping, and cursor movement. ```lua require('smart-splits').setup({ default_amount = 3, at_edge = 'wrap', move_cursor_same_row = false, }) ``` -------------------------------- ### Debug Logging Setup Source: https://github.com/mrjones2014/smart-splits.nvim/blob/master/_autodocs/README.md Enable debug logging for smart-splits.nvim to diagnose plugin issues. This involves setting the log level and optionally opening the log file. ```lua -- Set debug logging require('smart-splits').setup({ log_level = 'debug' }) -- Open log file require('smart-splits.log').open_log_file() ``` -------------------------------- ### Kitty Integration Configuration Source: https://github.com/mrjones2014/smart-splits.nvim/blob/master/README.md Configuration snippets for kitty.conf to enable smart-splits.nvim integration, including key mappings and remote control setup. ```APIDOC ## Kitty Integration ### Description Configuration for `~/.config/kitty/kitty.conf` to integrate `smart-splits.nvim` with Kitty. ### Key Mappings ```conf # Default mappings for neighboring windows map ctrl+j neighboring_window down map ctrl+k neighboring_window up map ctrl+h neighboring_window left map ctrl+l neighboring_window right # Unset mappings to pass keys to neovim when IS_NVIM is set map --when-focus-on var:IS_NVIM ctrl+j map --when-focus-on var:IS_NVIM ctrl+k map --when-focus-on var:IS_NVIM ctrl+h map --when-focus-on var:IS_NVIM ctrl+l # Resize pane mappings (adjust '3' as needed) map alt+j kitten relative_resize.py down 3 map alt+k kitten relative_resize.py up 3 map alt+h kitten relative_resize.py left 3 map alt+l kitten relative_resize.py right 3 # Unset resize mappings to pass keys to neovim when IS_NVIM is set map --when-focus-on var:IS_NVIM alt+j map --when-focus-on var:IS_NVIM alt+k map --when-focus-on var:IS_NVIM alt+h map --when-focus-on var:IS_NVIM alt+l ``` ### Remote Control Setup **Option 1: Command Line** ```bash # For Linux: kitty -o allow_remote_control=yes --single-instance --listen-on unix:@mykitty # Other Unix systems: kitty -o allow_remote_control=yes --single-instance --listen-on unix:/tmp/mykitty ``` **Option 2: `kitty.conf`** ```conf # For Linux: allow_remote_control yes listen_on unix:@mykitty # Other Unix systems: allow_remote_control yes listen_on unix:/tmp/mykitty ``` ### Nvim over SSH with Kitty **Prerequisites:** Remote machine must have Nvim and `smart-splits.nvim` installed. **Configuration:** 1. **Local `~/.config/kitty/ssh.conf`:** ```conf forward_remote_control yes ``` 2. **Local `~/.config/kitty/kitty.conf` (ensure unix file-based socket): ```conf listen_on unix:/tmp/mykitty ``` **Usage:** ```bash kitten ssh user@remotehost ``` **Note:** `forward_remote_control` grants the remote host full access to your local computer. Use only for trusted remote hosts. ``` -------------------------------- ### Bind Keys for smart-splits.nvim Operations Source: https://github.com/mrjones2014/smart-splits.nvim/blob/master/_autodocs/README.md Set up keybindings for common split pane management actions like resizing, moving the cursor, and swapping buffers. These examples use Neovim's keymap API. ```lua vim.keymap.set('n', '', require('smart-splits').resize_left) vim.keymap.set('n', '', require('smart-splits').move_cursor_left) vim.keymap.set('n', 'h', require('smart-splits').swap_buf_left) ``` -------------------------------- ### Get Multiplexer Backend Source: https://github.com/mrjones2014/smart-splits.nvim/blob/master/_autodocs/api-reference/multiplexer-api.md Access the current multiplexer backend implementation using `require('smart-splits.mux').get()`. ```lua mux.get() ``` -------------------------------- ### File Log Output Example Source: https://github.com/mrjones2014/smart-splits.nvim/blob/master/_autodocs/api-reference/logging.md All log messages are written to a file, including timestamp, plugin name, log level, and the message itself. This provides a persistent record of events. ```log [2024-01-15 10:30:45][smart-splits.nvim] [debug] Detected multiplexer: tmux [2024-01-15 10:30:45][smart-splits.nvim] [info] Resizing split: direction=left, amount=3 [2024-01-15 10:30:46][smart-splits.nvim] [warn] Kitty integration: wrap not supported ``` -------------------------------- ### WezTerm Lua Configuration for Smart Splits Source: https://github.com/mrjones2014/smart-splits.nvim/blob/master/doc/smart-splits.nvim.txt Configure WezTerm to use smart-splits.nvim for pane navigation and resizing. This example shows how to define directional keys and modifiers for moving and resizing panes, with a fallback to sending keys to Neovim when it's focused. ```lua local w = require('wezterm') -- if you are *NOT* lazy-loading smart-splits.nvim (recommended) local function is_vim(pane) -- this is set by the plugin, and unset on ExitPre in Neovim return pane:get_user_vars().IS_NVIM == 'true' end -- if you *ARE* lazy-loading smart-splits.nvim (not recommended) -- you have to use this instead, but note that this will not work -- in all cases (e.g. over an SSH connection). Also note that -- `pane:get_foreground_process_name()` can have high and highly variable -- latency, so the other implementation of `is_vim()` will be more -- performant as well. local function is_vim(pane) -- This gsub is equivalent to POSIX basename(3) -- Given "/foo/bar" returns "bar" -- Given "c:\\foo\\bar" returns "bar" local process_name = string.gsub(pane:get_foreground_process_name(), '(.*[/\])(.*)', '%2') return process_name == 'nvim' or process_name == 'vim' end local direction_keys = { h = 'Left', j = 'Down', k = 'Up', l = 'Right', } local function split_nav(resize_or_move, key) return { key = key, mods = resize_or_move == 'resize' and 'META' or 'CTRL', action = w.action_callback(function(win, pane) if is_vim(pane) then -- pass the keys through to vim/nvim win:perform_action({ SendKey = { key = key, mods = resize_or_move == 'resize' and 'META' or 'CTRL' }, }, pane) else if resize_or_move == 'resize' then win:perform_action({ AdjustPaneSize = { direction_keys[key], 3 } }, pane) else win:perform_action({ ActivatePaneDirection = direction_keys[key] }, pane) end end end), } end return { keys = { -- move between split panes split_nav('move', 'h'), split_nav('move', 'j'), split_nav('move', 'k'), split_nav('move', 'l'), -- resize panes split_nav('resize', 'h'), split_nav('resize', 'j'), split_nav('resize', 'k'), split_nav('resize', 'l'), }, } ``` -------------------------------- ### Configure Submode.nvim for Window Resizing with Smart-Splits Source: https://github.com/mrjones2014/smart-splits.nvim/blob/master/README.md This configuration sets up submode.nvim to enter a 'WinResize' mode. Within this mode, directional keys (h, j, k, l, and arrow keys) are mapped to smart-splits.nvim's resize functions. Ensure both plugins are installed and listed as dependencies. ```lua { 'mrjones2014/smart-splits.nvim', event = 'VeryLazy', dependencies = { 'pogyomo/submode.nvim', }, config = function() -- Resize local submode = require 'submode' submode.create('WinResize', { mode = 'n', enter = 'r', leave = { '', 'q', '' }, hook = { on_enter = function() vim.notify 'Use { h, j, k, l } or { , , , } to resize the window' end, on_leave = function() vim.notify '' end, }, default = function(register) register('h', require('smart-splits').resize_left, { desc = 'Resize left' }) register('j', require('smart-splits').resize_down, { desc = 'Resize down' }) register('k', require('smart-splits').resize_up, { desc = 'Resize up' }) register('l', require('smart-splits').resize_right, { desc = 'Resize right' }) register('', require('smart-splits').resize_left, { desc = 'Resize left' }) register('', require('smart-splits').resize_down, { desc = 'Resize down' }) register('', require('smart-splits').resize_up, { desc = 'Resize up' }) register('', require('smart-splits').resize_right, { desc = 'Resize right' }) end, }) end, } ``` -------------------------------- ### Kitty Terminal Keybindings for Smart Splits Source: https://github.com/mrjones2014/smart-splits.nvim/blob/master/README.md Configure Kitty terminal to use smart-splits.nvim for window navigation and resizing. This setup allows seamless switching between Kitty's native window management and Neovim's split pane control. ```kittyconfig map ctrl+j neighboring_window down map ctrl+k neighboring_window up map ctrl+h neighboring_window left map ctrl+l neighboring_window right # Unset the mapping to pass the keys to neovim map --when-focus-on var:IS_NVIM ctrl+j map --when-focus-on var:IS_NVIM ctrl+k map --when-focus-on var:IS_NVIM ctrl+h map --when-focus-on var:IS_NVIM ctrl+l # the 3 here is the resize amount, adjust as needed map alt+j kitten relative_resize.py down 3 map alt+k kitten relative_resize.py up 3 map alt+h kitten relative_resize.py left 3 map alt+l kitten relative_resize.py right 3 map --when-focus-on var:IS_NVIM alt+j map --when-focus-on var:IS_NVIM alt+k map --when-focus-on var:IS_NVIM alt+h map --when-focus-on var:IS_NVIM alt+l ``` -------------------------------- ### Get Window Position - Lua Source: https://github.com/mrjones2014/smart-splits.nvim/blob/master/_autodocs/api-reference/window-utilities.md Determine the position of the current window relative to a given direction (left, right, up, down). Returns an enum value indicating if the window is at the start, middle, or end. ```lua local win = require('smart-splits.win') local pos = win.win_position('left') if pos == win.WinPosition.start then print('At left edge') elseif pos == win.WinPosition.middle then print('In middle') else print('At right edge') end ``` -------------------------------- ### Get Neighbor Window ID - Lua Source: https://github.com/mrjones2014/smart-splits.nvim/blob/master/_autodocs/api-reference/window-utilities.md Get the window ID of a neighbor window in a specified direction. Returns the window ID or nil if no neighbor exists in that direction. ```lua local win = require('smart-splits.win') local right_win = win.neighbor_win_id('l') if right_win then print('Window to the right has ID:', right_win) end ``` -------------------------------- ### get Source: https://github.com/mrjones2014/smart-splits.nvim/blob/master/_autodocs/api-reference/multiplexer-api.md Get the currently active multiplexer backend. Returns the multiplexer backend corresponding to the current terminal environment (tmux, wezterm, kitty, zellij) or nil if multiplexer integration is disabled or unavailable. ```APIDOC ## get ### Description Get the currently active multiplexer backend. ### Returns `SmartSplitsMultiplexer` instance or `nil` if no multiplexer is enabled ### Behavior Returns the multiplexer backend corresponding to the current terminal environment (tmux, wezterm, kitty, zellij) or nil if multiplexer integration is disabled or unavailable. ### Example ```lua local mux = require('smart-splits.mux').get() if mux then print('Using multiplexer:', mux.type) else print('No multiplexer active') end ``` ``` -------------------------------- ### Pre-Load Configuration for Lazy Loading Source: https://github.com/mrjones2014/smart-splits.nvim/blob/master/_autodocs/configuration.md Set multiplexer integration and Kitty password before loading the plugin with lazy.nvim. ```lua -- Set before plugin loads vim.g.smart_splits_multiplexer_integration = 'tmux' vim.g.smart_splits_kitty_password = 'password' -- Then load plugin require('lazy').setup({ 'mrjones2014/smart-splits.nvim', }) ``` -------------------------------- ### Find Window Position Source: https://github.com/mrjones2014/smart-splits.nvim/blob/master/_autodocs/README.md Get the position of a window relative to a given direction. Checks if the window is at the specified edge. ```lua local pos = require('smart-splits').win_position('left') if pos == 0 then print('At left edge') end ``` -------------------------------- ### Configure smart-splits.nvim Options Source: https://github.com/mrjones2014/smart-splits.nvim/blob/master/doc/smart-splits.nvim.txt Set various configuration options for smart-splits.nvim to customize its behavior. Options include edge behavior, floating window handling, cursor movement, ignored events, and multiplexer integration. ```lua require('smart-splits').setup({ -- 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', -- Desired behavior when the current window is floating: -- 'previous' => Focus previous Vim window and perform action -- 'mux' => Always forward action to multiplexer float_win_behavior = 'previous', -- 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, -- 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. -- You can also set this value by setting `vim.g.smart_splits_multiplexer_integration` -- before the plugin is loaded (e.g. for lazy environments). multiplexer_integration = nil, -- disable multiplexer navigation if current multiplexer pane is zoomed -- NOTE: This does not work on Zellij as there is no way to determine the -- pane zoom state outside of the Zellij Plugin API, which does not apply here 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, -- In Zellij, set this to true if you would like to move to the next *tab* -- when the current pane is at the edge of the zellij tab/window zellij_move_focus_or_tab = false, -- default logging level, one of: 'trace'|'debug'|'info'|'warn'|'error'|'fatal' log_level = 'info', }) ``` -------------------------------- ### WinPosition Enumeration Source: https://github.com/mrjones2014/smart-splits.nvim/blob/master/_autodocs/api-reference/window-utilities.md Defines possible positions for a window relative to its neighbors in a given direction: start, middle, or last. ```lua ---@enum WinPosition M.WinPosition = { start = 0, -- At start/edge in direction middle = 1, -- In the middle last = 2, -- At end/edge in direction } ``` -------------------------------- ### Recommended Key Mappings for smart-splits.nvim Source: https://github.com/mrjones2014/smart-splits.nvim/blob/master/doc/smart-splits.nvim.txt Set up key mappings for resizing splits, moving between splits, and swapping buffers using smart-splits.nvim functions. Note that some terminals on macOS may require configuration to treat the Option key as Alt. ```lua -- recommended mappings -- resizing splits -- these keymaps will also accept a range, -- for example `10` will `resize_left` by `(10 * config.default_amount)` vim.keymap.set('n', '', require('smart-splits').resize_left) vim.keymap.set('n', '', require('smart-splits').resize_down) vim.keymap.set('n', '', require('smart-splits').resize_up) vim.keymap.set('n', '', require('smart-splits').resize_right) -- moving between splits vim.keymap.set('n', '', require('smart-splits').move_cursor_left) vim.keymap.set('n', '', require('smart-splits').move_cursor_down) vim.keymap.set('n', '', require('smart-splits').move_cursor_up) vim.keymap.set('n', '', require('smart-splits').move_cursor_right) vim.keymap.set('n', '', require('smart-splits').move_cursor_previous) -- swapping buffers between windows vim.keymap.set('n', 'h', require('smart-splits').swap_buf_left) vim.keymap.set('n', 'j', require('smart-splits').swap_buf_down) vim.keymap.set('n', 'k', require('smart-splits').swap_buf_up) vim.keymap.set('n', 'l', require('smart-splits').swap_buf_right) ``` -------------------------------- ### Configuration Source: https://github.com/mrjones2014/smart-splits.nvim/blob/master/_autodocs/INDEX.md Function to set up the Smart Splits nvim configuration. ```APIDOC ## Configuration ### `setup(config)` Initializes Smart Splits nvim with the provided configuration object. ``` -------------------------------- ### WinPosition Enum Source: https://github.com/mrjones2014/smart-splits.nvim/blob/master/_autodocs/types.md Represents the position of a window relative to its neighbors in a given direction. It can be at the start, middle, or last position. ```APIDOC ## WinPosition Enum ### Description An enum representing where a window sits relative to its split neighbors in a given direction. It indicates if the window is at the start/edge, in the middle, or at the end/edge of the layout. ### Values - `start` (0) - The window is at the start or top edge of the layout in the specified direction. - `middle` (1) - The window is in the middle of the layout, with neighbors on both sides. - `last` (2) - The window is at the end or bottom edge of the layout in the specified direction. ### Usage This enum is returned by `require('smart-splits').win_position(direction)`. ``` -------------------------------- ### Multiplexer Lua API Source: https://github.com/mrjones2014/smart-splits.nvim/blob/master/doc/smart-splits.nvim.txt Access the multiplexer API directly for scripting purposes. Get a handle to the current multiplexer backend. ```APIDOC ## Multiplexer Lua API You can directly access the multiplexer API for scripting purposes as well. To get a handle to the current multiplexer backend, you can do: ```lua local mux = require('smart-splits.mux').get() ``` This returns the currently enabled multiplexer backend, or `nil` if none is currently in use. The API offers the following methods: ```lua local mux = require('smart-splits.mux').get() -- mux matches the following type annotations --@class SmartSplitsMultiplexer --@field current_pane_id fun():number|nil --@field current_pane_at_edge fun(direction:'left'|'right'|'up'|'down'):boolean --@field is_in_session fun():boolean --@field current_pane_is_zoomed fun():boolean --@field next_pane fun(direction:'left'|'right'|'up'|'down'):boolean --@field resize_pane fun(direction:'left'|'right'|'up'|'down', amount:number):boolean --@field split_pane fun(direction:'left'|'right'|'up'|'down',size:number|nil):boolean --@field type 'tmux'|'wezterm'|'kitty'|'zellij' ``` ``` -------------------------------- ### Initialize and Configure Smart Splits Source: https://github.com/mrjones2014/smart-splits.nvim/blob/master/_autodocs/api-reference/core-functions.md Call this function once during plugin initialization to apply user configuration and validate settings. It integrates with the multiplexer. ```lua require('smart-splits').setup({ ignored_buftypes = { 'nofile', 'quickfix' }, default_amount = 3, at_edge = 'wrap', move_cursor_same_row = false, }) ``` -------------------------------- ### Get Current Pane ID Source: https://github.com/mrjones2014/smart-splits.nvim/blob/master/_autodocs/api-reference/multiplexer-api.md Retrieve the unique identifier for the current pane. The return type (number or string) and format vary by backend. ```lua mux.current_pane_id() ``` -------------------------------- ### Key Mappings Source: https://github.com/mrjones2014/smart-splits.nvim/blob/master/doc/smart-splits.nvim.txt Recommended key mappings for resizing and moving between splits, and swapping buffers. ```APIDOC ## Key Mappings ### Description Recommended key mappings for resizing splits, moving between splits, and swapping buffers. ### Resizing Splits - **``**: `require('smart-splits').resize_left` - **``**: `require('smart-splits').resize_down` - **``**: `require('smart-splits').resize_up` - **``**: `require('smart-splits').resize_right` *Note: These mappings accept a range, e.g., `10` will resize left by `(10 * config.default_amount)`.* ### Moving Between Splits - **``**: `require('smart-splits').move_cursor_left` - **``**: `require('smart-splits').move_cursor_down` - **``**: `require('smart-splits').move_cursor_up` - **``**: `require('smart-splits').move_cursor_right` - **``**: `require('smart-splits').move_cursor_previous` ### Swapping Buffers Between Windows - **`h`**: `require('smart-splits').swap_buf_left` - **`j`**: `require('smart-splits').swap_buf_down` - **`k`**: `require('smart-splits').swap_buf_up` - **`l`**: `require('smart-splits').swap_buf_right` ``` -------------------------------- ### Get Multiplexer Backend Handle (Lua) Source: https://github.com/mrjones2014/smart-splits.nvim/blob/master/doc/smart-splits.nvim.txt Retrieve the current multiplexer backend instance for programmatic access. Returns nil if no multiplexer is active. ```lua local mux = require('smart-splits.mux').get() ``` -------------------------------- ### Key Mappings - Swapping Buffers Source: https://github.com/mrjones2014/smart-splits.nvim/blob/master/README.md Recommended key mappings for swapping buffers between adjacent splits. ```APIDOC ## Key Mappings - Swapping Buffers ### `swap_buf_left` Maps to `h` for swapping the buffer with the left split. ### `swap_buf_down` Maps to `j` for swapping the buffer with the split below. ### `swap_buf_up` Maps to `k` for swapping the buffer with the split above. ### `swap_buf_right` Maps to `l` for swapping the buffer with the right split. ``` -------------------------------- ### Smart Splits Plugin File Types Source: https://github.com/mrjones2014/smart-splits.nvim/blob/master/_autodocs/EXPORTS_INVENTORY.md Defines specific file types that the plugin can recognize or interact with. 'NvimTree' is mentioned as an example of a user-configurable file type. ```lua 'NvimTree' (user-configurable) ``` -------------------------------- ### Execute System Commands with Utilities Source: https://github.com/mrjones2014/smart-splits.nvim/blob/master/_autodocs/api-reference/utilities.md Use the `utils.system` function to execute CLI commands for multiplexer backends like Tmux, Wezterm, and Kitty. It returns the command's output and exit code. ```lua local output, code = utils.system({'tmux', '-S', socket, 'list-panes'}) ``` ```lua local output, code = utils.system({'wezterm', 'cli', 'list', '--format', 'json'}) ``` ```lua local output, code = utils.system({'kitty', '@', 'ls', '--format=json'}) ``` -------------------------------- ### Lazy Loading Configuration Module Source: https://github.com/mrjones2014/smart-splits.nvim/blob/master/_autodocs/MODULE_STRUCTURE.md Demonstrates how to access configuration settings using a lazy-loaded metatable. Modules like config, mux, and log are loaded only upon their first use to minimize startup overhead. ```lua local config = lazy.require_on_index('smart-splits.config') -- Accessing config.default_amount doesn't load until first access ``` -------------------------------- ### Configuration Source: https://github.com/mrjones2014/smart-splits.nvim/blob/master/_autodocs/EXPORTS_INVENTORY.md Applies configuration settings to the Smart Splits plugin. ```APIDOC ## setup(config) ### Description Applies configuration settings to the Smart Splits plugin. ### Method `setup` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **config** (table) - Required - The configuration table for Smart Splits. ``` -------------------------------- ### Multiplexer Functions Source: https://github.com/mrjones2014/smart-splits.nvim/blob/master/_autodocs/EXPORTS_INVENTORY.md Provides functions to interact with the multiplexer, such as getting the current multiplexer, checking if it's enabled, moving panes, resizing panes, and splitting panes. ```APIDOC ## require('smart-splits.mux') ### Description Functions to control and query the multiplexer. ### Functions - `get(): SmartSplitsMultiplexer|nil` - Retrieves the current multiplexer instance. - `is_enabled(): boolean` - Checks if the multiplexer is currently enabled. - `move_pane(direction: SmartSplitsDirection, will_wrap: boolean, at_edge?: SmartSplitsAtEdgeBehavior): boolean` - Moves the current pane in the specified direction. - `resize_pane(direction: SmartSplitsDirection, amount: number): boolean` - Resizes the current pane in the specified direction by the given amount. - `split_pane(direction: SmartSplitsDirection, size?: number): boolean` - Splits the current pane in the specified direction with an optional size. - `update_layout_details(): nil` - Updates the layout details of the multiplexer. ``` -------------------------------- ### Configuration Module Source: https://github.com/mrjones2014/smart-splits.nvim/blob/master/_autodocs/EXPORTS_INVENTORY.md This section details the configuration options and methods available in the `require('smart-splits.config')` module, allowing users to customize the behavior of smart-splits.nvim. ```APIDOC ## Configuration Module ### `require('smart-splits.config')` **Configuration Fields (read/write):** - `ignored_buftypes: string[]` - List of buffer types to ignore. - `ignored_filetypes: string[]` - List of file types to ignore. - `default_amount: number` - The default amount for resize operations. - `at_edge: SmartSplitsAtEdgeBehavior` - Behavior when resizing reaches the edge of the screen. - `float_win_behavior: SmartSplitsFloatWinBehavior` - Behavior for floating windows. - `move_cursor_same_row: boolean` - Whether the cursor should stay on the same row when moving. - `cursor_follows_swapped_bufs: boolean` - Whether the cursor should follow swapped buffers. - `ignored_events: string[]` - List of events to ignore. - `multiplexer_integration: SmartSplitsMultiplexerType|false|nil` - Integration type for multiplexer tools. - `disable_multiplexer_nav_when_zoomed: boolean` - Disable multiplexer navigation when a window is zoomed. - `wezterm_cli_path: string|nil` - Path to the WezTerm CLI. - `kitty_password: string|nil` - Password for Kitty terminal integration. - `zellij_move_focus_or_tab: boolean` - Behavior for moving focus or tabs in Zellij. - `log_level: 'trace'|'debug'|'info'|'warn'|'error'|'fatal'` - The logging level for the plugin. **Methods:** - `setup(new_config: table): nil` - Updates the plugin configuration with a new table of settings. - `set_default_multiplexer(): string|nil` - Sets the default multiplexer for the plugin. ``` -------------------------------- ### Get Active Multiplexer Backend Source: https://github.com/mrjones2014/smart-splits.nvim/blob/master/_autodocs/api-reference/multiplexer-api.md Retrieves the currently active multiplexer backend instance. Returns nil if no multiplexer is enabled or available in the current terminal environment. ```lua local mux = require('smart-splits.mux').get() if mux then print('Using multiplexer:', mux.type) else print('No multiplexer active') end ``` -------------------------------- ### Configure Submode for Window Resizing with Smart Splits Source: https://github.com/mrjones2014/smart-splits.nvim/blob/master/doc/smart-splits.nvim.txt Integrates smart-splits.nvim with submode.nvim to enable persistent window resizing using directional keys without modifiers. Configure the 'WinResize' submode to map keys to smart-splits resize functions. ```lua { 'mrjones2014/smart-splits.nvim', event = 'VeryLazy', dependencies = { 'pogyomo/submode.nvim', }, config = function() -- Resize local submode = require 'submode' submode.create('WinResize', { mode = 'n', enter = 'r', leave = { '', 'q', '' }, hook = { on_enter = function() vim.notify 'Use { h, j, k, l } or { , , , } to resize the window' end, on_leave = function() vim.notify '' end }, default = function(register) register('h', require('smart-splits').resize_left, { desc = 'Resize left' }) register('j', require('smart-splits').resize_down, { desc = 'Resize down' }) register('k', require('smart-splits').resize_up, { desc = 'Resize up' }) register('l', require('smart-splits').resize_right, { desc = 'Resize right' }) register('', require('smart-splits').resize_left, { desc = 'Resize left' }) register('', require('smart-splits').resize_down, { desc = 'Resize down' }) register('', require('smart-splits').resize_up, { desc = 'Resize up' }) end }) end } ``` -------------------------------- ### Key Mappings - Moving Between Splits Source: https://github.com/mrjones2014/smart-splits.nvim/blob/master/README.md Recommended key mappings for moving the cursor between splits. ```APIDOC ## Key Mappings - Moving Between Splits ### `move_cursor_left` Maps to `` for moving the cursor to the left split. ### `move_cursor_down` Maps to `` for moving the cursor to the split below. ### `move_cursor_up` Maps to `` for moving the cursor to the split above. ### `move_cursor_right` Maps to `` for moving the cursor to the right split. ### `move_cursor_previous` Maps to `` for moving the cursor to the previous split. ``` -------------------------------- ### WinPosition Enum Definition Source: https://github.com/mrjones2014/smart-splits.nvim/blob/master/_autodocs/types.md Defines the 'WinPosition' enum, representing where a window is located relative to its neighbors in a layout. Values indicate if the window is at the start, middle, or end of the layout in a given direction. ```lua ---@enum WinPosition M.WinPosition = { start = 0, -- At the start/edge of the layout in a direction middle = 1, -- In the middle of the layout last = 2, -- At the end/edge of the layout in a direction } ``` -------------------------------- ### Key Mappings - Resizing Splits Source: https://github.com/mrjones2014/smart-splits.nvim/blob/master/README.md Recommended key mappings for resizing splits. These mappings can also accept a range, e.g., `10` will resize left by `(10 * config.default_amount)`. ```APIDOC ## Key Mappings - Resizing Splits ### `resize_left` Maps to `` for resizing splits to the left. ### `resize_down` Maps to `` for resizing splits downwards. ### `resize_up` Maps to `` for resizing splits upwards. ### `resize_right` Maps to `` for resizing splits to the right. ```