Skip to content

Commit 4a0bba0

Browse files
authored
Merge branch 'main' into readme
2 parents 68e9dcc + b6f42bf commit 4a0bba0

File tree

4 files changed

+51
-5
lines changed

4 files changed

+51
-5
lines changed

lua/tmux/navigation/navigate.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ function M.to(direction)
2929
log.debug("navigate_to: " .. direction)
3030

3131
local is_nvim_border = nvim.is_nvim_border(direction)
32-
if is_nvim_border and M.has_tmux_target(direction) then
32+
if (nvim.is_nvim_float() or is_nvim_border) and M.has_tmux_target(direction) then
3333
tmux.change_pane(direction)
3434
elseif is_nvim_border and options.navigation.cycle_navigation then
3535
nvim.wincmd(opposite_directions[direction], 999)

lua/tmux/resize.lua

+4-4
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ end
3838
function M.to_left(step)
3939
step = step or options.resize.resize_step_x
4040
local is_border = nvim.is_nvim_border("l")
41-
if is_border and is_tmux_target("l") then
41+
if (nvim.is_nvim_float() or is_border) and is_tmux_target("l") then
4242
tmux.resize("h", step)
4343
elseif is_border then
4444
nvim.resize("x", "+", step)
@@ -50,7 +50,7 @@ end
5050
function M.to_bottom(step)
5151
step = step or options.resize.resize_step_y
5252
local is_border = nvim.is_nvim_border("j")
53-
if is_border and is_tmux_target("j") then
53+
if (nvim.is_nvim_float() or is_border) and is_tmux_target("j") then
5454
tmux.resize("j", step)
5555
elseif is_border then
5656
nvim.resize("y", "-", step)
@@ -62,7 +62,7 @@ end
6262
function M.to_top(step)
6363
step = step or options.resize.resize_step_y
6464
local is_border = nvim.is_nvim_border("j")
65-
if is_border and is_tmux_target("j") then
65+
if (nvim.is_nvim_float() or is_border) and is_tmux_target("j") then
6666
tmux.resize("k", step)
6767
elseif is_border then
6868
nvim.resize("y", "+", step)
@@ -74,7 +74,7 @@ end
7474
function M.to_right(step)
7575
step = step or options.resize.resize_step_x
7676
local is_border = nvim.is_nvim_border("l")
77-
if is_border and is_tmux_target("l") then
77+
if (nvim.is_nvim_float() or is_border) and is_tmux_target("l") then
7878
tmux.resize("l", step)
7979
elseif is_border then
8080
nvim.resize("x", "-", step)

lua/tmux/wrapper/nvim.lua

+4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ function M.is_nvim_border(border)
33
return M.winnr() == M.winnr("1" .. border)
44
end
55

6+
function M.is_nvim_float()
7+
return vim.api.nvim_win_get_config(0).relative ~= ""
8+
end
9+
610
function M.resize(axis, direction, step_size)
711
local command = "resize "
812
if axis == "x" then

spec/tmux/navigation/navigate_spec.lua

+42
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,9 @@ describe("navigate.to", function()
168168
nvim.is_nvim_border = function()
169169
return false
170170
end
171+
nvim.is_nvim_float = function()
172+
return false
173+
end
171174

172175
local last_called_direction = ""
173176
nvim.wincmd = function(direction)
@@ -195,6 +198,9 @@ describe("navigate.to", function()
195198
nvim.is_nvim_border = function()
196199
return true
197200
end
201+
nvim.is_nvim_float = function()
202+
return false
203+
end
198204

199205
local last_called_direction = ""
200206
nvim.wincmd = function(direction)
@@ -222,6 +228,9 @@ describe("navigate.to", function()
222228
nvim.is_nvim_border = function()
223229
return true
224230
end
231+
nvim.is_nvim_float = function()
232+
return false
233+
end
225234

226235
local last_called_direction = ""
227236
nvim.wincmd = function(direction, count)
@@ -250,6 +259,39 @@ describe("navigate.to", function()
250259
nvim.is_nvim_border = function()
251260
return true
252261
end
262+
nvim.is_nvim_float = function()
263+
return false
264+
end
265+
266+
local last_called_direction = ""
267+
tmux.change_pane = function(direction)
268+
last_called_direction = direction
269+
end
270+
271+
navigate.to("h")
272+
assert.are.same("h", last_called_direction)
273+
274+
navigate.to("j")
275+
assert.are.same("j", last_called_direction)
276+
277+
navigate.to("k")
278+
assert.are.same("k", last_called_direction)
279+
280+
navigate.to("l")
281+
assert.are.same("l", last_called_direction)
282+
end)
283+
284+
it("check with nvim float win", function()
285+
options.navigation.cycle_navigation = true
286+
navigate.has_tmux_target = function()
287+
return true
288+
end
289+
nvim.is_nvim_border = function()
290+
return false
291+
end
292+
nvim.is_nvim_float = function()
293+
return true
294+
end
253295

254296
local last_called_direction = ""
255297
tmux.change_pane = function(direction)

0 commit comments

Comments
 (0)