Skip to content

Commit

Permalink
Merge pull request #168 from pwnalone/master
Browse files Browse the repository at this point in the history
fix: Detect and handle nested Vim instances in Tmux
  • Loading branch information
mrjones2014 authored Mar 21, 2024
2 parents 83bdcc3 + b0d5b25 commit 756d90e
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lua/smart-splits/mux/tmux.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ local types = require('smart-splits.types')
local Direction = types.Direction
local log = require('smart-splits.log')

local is_nested_vim = false

local dir_keys_tmux = {
[Direction.left] = 'L',
[Direction.right] = 'R',
Expand Down Expand Up @@ -152,13 +154,20 @@ function M.on_init()
log.warn('tmux init: could not detect pane ID!')
return
end
if tonumber(tmux_exec({ 'show-options', '-pqvt', pane_id, '@pane-is-vim' })) == 1 then
is_nested_vim = true
return
end
tmux_exec({ 'set-option', '-pt', pane_id, '@pane-is-vim', 1 })
if vim.v.shell_error ~= 0 then
log.warn('tmux init: failed to detect pane_id')
end
end

function M.on_exit()
if is_nested_vim then
return
end
local pane_id = M.current_pane_id()
if not pane_id then
log.warn('tmux init: could not detect pane ID!')
Expand Down

0 comments on commit 756d90e

Please sign in to comment.