All Projects → aserowy → tmux.nvim

aserowy / tmux.nvim

Licence: MIT license
tmux integration for nvim features pane movement and resizing from within nvim.

Programming Languages

lua
6591 projects
Nix
1067 projects
Dockerfile
14818 projects

Projects that are alternatives of or similar to tmux.nvim

.dotfiles
💻 My settings for macOS, kitty, zsh, nvim, tmux, and more 🛠
Stars: ✭ 44 (-85.28%)
Mutual labels:  tmux, tmux-configuration, neovim-lua
Nvimux
Neovim as a TMUX replacement
Stars: ✭ 302 (+1%)
Mutual labels:  tmux, neovim-plugin
dotfiles
❤ ~/.🛠🐈 the daily jam 🍞🥜🍇🍞
Stars: ✭ 55 (-81.61%)
Mutual labels:  tmux, tmux-configuration
tummy
Use a Tmuxfile with your tmux configuration to easily manage sessions
Stars: ✭ 54 (-81.94%)
Mutual labels:  tmux, tmux-configuration
muxed
Another TMUX project manager
Stars: ✭ 58 (-80.6%)
Mutual labels:  tmux, tmux-configuration
dotfiles
Dotfiles for Neovim (0.7+), Fish shell, git, Kitty, tmux, and more.
Stars: ✭ 54 (-81.94%)
Mutual labels:  tmux, tmux-configuration
nested-tmux
A simple tmux configuration for nested tmux sessions
Stars: ✭ 66 (-77.93%)
Mutual labels:  tmux, tmux-configuration
package-info.nvim
✍️ All the npm/yarn commands I don't want to type
Stars: ✭ 248 (-17.06%)
Mutual labels:  neovim-plugin, neovim-lua
.tmux
🇫🇷 Oh my tmux! My self-contained, pretty & versatile tmux configuration made with ❤️
Stars: ✭ 15,594 (+5115.38%)
Mutual labels:  tmux, tmux-configuration
Dotfiles
vim, zsh, git, homebrew, nvm, neovim - my whole world
Stars: ✭ 2,217 (+641.47%)
Mutual labels:  tmux, tmux-configuration
neogen
A better annotation generator. Supports multiple languages and annotation conventions.
Stars: ✭ 339 (+13.38%)
Mutual labels:  neovim-plugin, neovim-lua
modes.nvim
Prismatic line decorations for the adventurous vim user
Stars: ✭ 299 (+0%)
Mutual labels:  neovim-plugin, neovim-lua
Comment.nvim
🧠 💪 // Smart and powerful comment plugin for neovim. Supports treesitter, dot repeat, left-right/up-down motions, hooks, and more
Stars: ✭ 796 (+166.22%)
Mutual labels:  neovim-plugin, neovim-lua
onestatus
an api to customize tmux from vim
Stars: ✭ 82 (-72.58%)
Mutual labels:  tmux, neovim-plugin
nvim-hardline
A simple Neovim statusline
Stars: ✭ 122 (-59.2%)
Mutual labels:  neovim-plugin, neovim-lua
winshift.nvim
Rearrange your windows with ease.
Stars: ✭ 230 (-23.08%)
Mutual labels:  neovim-plugin, neovim-lua
which-key.nvim
💥 Create key bindings that stick. WhichKey is a lua plugin for Neovim 0.5 that displays a popup with possible keybindings of the command you started typing.
Stars: ✭ 2,043 (+583.28%)
Mutual labels:  neovim-plugin, neovim-lua
diffview.nvim
Single tabpage interface for easily cycling through diffs for all modified files for any git rev.
Stars: ✭ 1,472 (+392.31%)
Mutual labels:  neovim-plugin, neovim-lua
Tmux Complete.vim
Vim plugin for insert mode completion of words in adjacent tmux panes
Stars: ✭ 447 (+49.5%)
Mutual labels:  tmux, neovim-plugin
cmp-tmux
Tmux completion source for nvim-cmp and nvim-compe
Stars: ✭ 98 (-67.22%)
Mutual labels:  tmux, neovim-plugin

tmux.nvim

dependabot ci coverage

features

copy from nvim to nvim to tmux

tmux-copy.mp4

navigating from nvim into tmux panes

tmux-navigate.mp4

resizing nvim splits like tmux panes

tmux-resize.mp4

requirements

  • neovim >= 0.5

The plugin and .tmux.conf scripts are battle tested with

  • tmux 3.2a

installation

Install tmux.nvim with e.g. packer.nvim and run the setup function:

use({
    "aserowy/tmux.nvim",
    config = function() require("tmux").setup() end
})

configuration

The config step is only necessary to overwrite configuration defaults.

The following defaults are given:

{
    copy_sync = {
        -- enables copy sync. by default, all registers are synchronized.
        -- to control which registers are synced, see the `sync_*` options.
        enable = true,

        -- ignore specific tmux buffers e.g. buffer0 = true to ignore the
        -- first buffer or named_buffer_name = true to ignore a named tmux
        -- buffer with name named_buffer_name :)
        ignore_buffers = { empty = false },

        -- TMUX >= 3.2: all yanks (and deletes) will get redirected to system
        -- clipboard by tmux
        redirect_to_clipboard = false,

        -- offset controls where register sync starts
        -- e.g. offset 2 lets registers 0 and 1 untouched
        register_offset = 0,

        -- overwrites vim.g.clipboard to redirect * and + to the system
        -- clipboard using tmux. If you sync your system clipboard without tmux,
        -- disable this option!
        sync_clipboard = true,

        -- synchronizes registers *, +, unnamed, and 0 till 9 with tmux buffers.
        sync_registers = true,

        -- syncs deletes with tmux clipboard as well, it is adviced to
        -- do so. Nvim does not allow syncing registers 0 and 1 without
        -- overwriting the unnamed register. Thus, ddp would not be possible.
        sync_deletes = true,

        -- syncs the unnamed register with the first buffer entry from tmux.
        sync_unnamed = true,
    },
    navigation = {
        -- cycles to opposite pane while navigating into the border
        cycle_navigation = true,

        -- enables default keybindings (C-hjkl) for normal mode
        enable_default_keybindings = true,

        -- prevents unzoom tmux when navigating beyond vim border
        persist_zoom = false,
    },
    resize = {
        -- enables default keybindings (A-hjkl) for normal mode
        enable_default_keybindings = true,

        -- sets resize steps for x axis
        resize_step_x = 1,

        -- sets resize steps for y axis
        resize_step_y = 1,
    }
}

usage

Tmux.nvim uses only lua API. If you are not running the default keybindings, you can bind the following functions to your liking. Besides the bindings in nvim you need to add configuration to tmux.

copy sync

Copy sync uses tmux buffers as master clipboard for *, +, unnamed, and 0 - 9 registers. The sync does NOT rely on temporary files and works just with the given tmux API. Thus, making it less insecure :). The feature enables a nvim instace overarching copy/paste process! dd in one nvim instance, switch to the second and p your deletes.

If you sync your clipboard not with a standalone tmux, disable sync_clipboard to ensure nvim handles yanks and deletes alone.

This has some downsites, on really slow machines, calling registers or pasting will eventually produce minimal input lag by syncing registers in advance to ensure the correctness of state. To avoid this, disabling sync_registers will only redirect the * and + registers.

To redirect copies (and deletes) to clipboard, tmux must have the capability to do so. The plugin will just set -w on set-buffer. If your tmux need more configuration check out tmux-yank for an easy setup.

Ignoring buffers must have the form of buffer_name = true to enable an unsorted list in lua. This enhances the performance of checks - if a buffer is ignored or not - meaningfull.

navigation

To enable cycle-free navigation beyond nvim, add the following to your ~/.tmux.conf:

It is important to note, that your bindings in nvim must match the defined bindings in tmux! Otherwise the pass through will not have the seamless effect!

is_vim="ps -o state= -o comm= -t '#{pane_tty}' | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'"

bind-key -n 'C-h' if-shell "$is_vim" 'send-keys C-h' { if -F '#{pane_at_left}' '' 'select-pane -L' }
bind-key -n 'C-j' if-shell "$is_vim" 'send-keys C-j' { if -F '#{pane_at_bottom}' '' 'select-pane -D' }
bind-key -n 'C-k' if-shell "$is_vim" 'send-keys C-k' { if -F '#{pane_at_top}' '' 'select-pane -U' }
bind-key -n 'C-l' if-shell "$is_vim" 'send-keys C-l' { if -F '#{pane_at_right}' '' 'select-pane -R' }

bind-key -T copy-mode-vi 'C-h' if -F '#{pane_at_left}' '' 'select-pane -L'
bind-key -T copy-mode-vi 'C-j' if -F '#{pane_at_bottom}' '' 'select-pane -D'
bind-key -T copy-mode-vi 'C-k' if -F '#{pane_at_top}' '' 'select-pane -U'
bind-key -T copy-mode-vi 'C-l' if -F '#{pane_at_right}' '' 'select-pane -R'

Otherwise you can add:

is_vim="ps -o state= -o comm= -t '#{pane_tty}' | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'"

bind-key -n 'C-h' if-shell "$is_vim" 'send-keys C-h' 'select-pane -L'
bind-key -n 'C-j' if-shell "$is_vim" 'send-keys C-j' 'select-pane -D'
bind-key -n 'C-k' if-shell "$is_vim" 'send-keys C-k' 'select-pane -U'
bind-key -n 'C-l' if-shell "$is_vim" 'send-keys C-l' 'select-pane -R'

bind-key -T copy-mode-vi 'C-h' select-pane -L
bind-key -T copy-mode-vi 'C-j' select-pane -D
bind-key -T copy-mode-vi 'C-k' select-pane -U
bind-key -T copy-mode-vi 'C-l' select-pane -R

If you are using tmux plugin manager, you can add the following plugin. On a side note: This plugin sets the default keybindings and does not support cycle-free navigation:

set -g @plugin 'christoomey/vim-tmux-navigator'

run '~/.tmux/plugins/tpm/tpm'

To run custom bindings in nvim, make sure to set enable_default_keybindings to false. The following functions are used to navigate around windows and panes:

{
    [[<cmd>lua require("tmux").move_left()<cr>]],
    [[<cmd>lua require("tmux").move_bottom()<cr>]],
    [[<cmd>lua require("tmux").move_top()<cr>]],
    [[<cmd>lua require("tmux").move_right()<cr>]],
}

resize

Add the following bindings to your ~/.tmux.conf:

It is important to note, that your bindings in nvim must match the defined bindings in tmux! Otherwise the pass through will not have the seamless effect!

is_vim="ps -o state= -o comm= -t '#{pane_tty}' | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'"

bind -n 'M-h' if-shell "$is_vim" 'send-keys M-h' 'resize-pane -L 1'
bind -n 'M-j' if-shell "$is_vim" 'send-keys M-j' 'resize-pane -D 1'
bind -n 'M-k' if-shell "$is_vim" 'send-keys M-k' 'resize-pane -U 1'
bind -n 'M-l' if-shell "$is_vim" 'send-keys M-l' 'resize-pane -R 1'

bind-key -T copy-mode-vi M-h resize-pane -L 1
bind-key -T copy-mode-vi M-j resize-pane -D 1
bind-key -T copy-mode-vi M-k resize-pane -U 1
bind-key -T copy-mode-vi M-l resize-pane -R 1

To run custom bindings in nvim, make sure to not set enable_default_keybindings to true. The following functions are used to resize windows:

{
    [[<cmd>lua require("tmux").resize_left()<cr>]],
    [[<cmd>lua require("tmux").resize_bottom()<cr>]],
    [[<cmd>lua require("tmux").resize_top()<cr>]],
    [[<cmd>lua require("tmux").resize_right()<cr>]],
}

contribute

Contributed code must pass luacheck and be formatted with stylua. Besides formatting, all tests have to pass. Tests are written for busted.

If you are using nix-shell, you can start a nix-shell and run fac (format and check).

stylua lua/ && luacheck lua/ && busted --verbose

inspiration

clipboard harmonization

navigation & resizing

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].