editor.tmux-navigator

Seamless navigation between tmux panes and vim splits

Disable

This extra is enabled on a fresh install. Turn it off with :RafiExtras (Spacemx), or remove "editor.tmux-navigator" from extras in your rafi.json.

Keymaps

KeyDescriptionMode
C-hGo to Left Window𝐍 𝐓
C-jGo to Lower Window𝐍 𝐓
C-kGo to Upper Window𝐍 𝐓
C-lGo to Right Window𝐍 𝐓

Plugins

Source
lua/rafi/extras/editor/tmux-navigator.lua
-- Seamless navigation between tmux panes and vim splits

if not vim.env.TMUX or vim.uv.os_uname().sysname == 'Windows_NT' then
	return
end

-- Eager: tiny, and the maps must work immediately.
vim.g.tmux_navigator_no_mappings = 1
vim.pack.add({ 'https://github.com/christoomey/vim-tmux-navigator' })

local function map()
	-- stylua: ignore start
	vim.keymap.set({ 'n', 't' }, '<C-h>', '<cmd>TmuxNavigateLeft<CR>', { silent = true, desc = 'Go to Left Window' })
	vim.keymap.set({ 'n', 't' }, '<C-j>', '<cmd>TmuxNavigateDown<CR>', { silent = true, desc = 'Go to Lower Window' })
	vim.keymap.set({ 'n', 't' }, '<C-k>', '<cmd>TmuxNavigateUp<CR>', { silent = true, desc = 'Go to Upper Window' })
	vim.keymap.set({ 'n', 't' }, '<C-l>', '<cmd>TmuxNavigateRight<CR>', { silent = true, desc = 'Go to Right Window' })
	-- stylua: ignore end
end

map()
-- rafi.config.keymaps sets its own <C-h/j/k/l> window maps after startup,
-- re-apply after.
vim.api.nvim_create_autocmd('User', {
	pattern = 'RafiKeymaps',
	once = true,
	callback = map,
})