diff --git a/ghostty/config b/ghostty/config index e7a2af3..ebd1de6 100644 --- a/ghostty/config +++ b/ghostty/config @@ -53,10 +53,10 @@ background = #000000 # navigate between splits (vim-style) # super+h requires remapping "Hide Ghostty" in macOS keyboard settings -keybind = super+h=goto_split:left -keybind = super+j=goto_split:bottom -keybind = super+k=goto_split:top -keybind = super+l=goto_split:right +keybind = unconsumed:super+h=goto_split:left +keybind = unconsumed:super+j=goto_split:bottom +keybind = unconsumed:super+k=goto_split:top +keybind = unconsumed:super+l=goto_split:right # resize splits keybind = super+right=resize_split:right,50 diff --git a/nvim/init.lua b/nvim/init.lua index 79a5928..d4e01c0 100644 --- a/nvim/init.lua +++ b/nvim/init.lua @@ -185,20 +185,31 @@ keymap("x", "K", ":move '<-2gv-gv", opts) keymap("x", "J", ":move '>+1gv-gv", opts) local function winnav(direction) - local win_directions = { h = "h", j = "j", k = "k", l = "l" } - vim.cmd("wincmd " .. win_directions[direction]) + local before = vim.fn.winnr() + vim.cmd("wincmd " .. direction) + if vim.fn.winnr() == before then + local map = { h = "left", j = "bottom", k = "top", l = "right" } + vim.fn.system({ + "osascript", + "-e", + string.format( + 'tell application "Ghostty" to perform action "goto_split:%s" on focused terminal of selected tab of front window', + map[direction] + ), + }) + end end -keymap("n", "", function() +keymap("n", "", function() winnav("h") end, opts) -keymap("n", "", function() +keymap("n", "", function() winnav("j") end, opts) -keymap("n", "", function() +keymap("n", "", function() winnav("k") end, opts) -keymap("n", "", function() +keymap("n", "", function() winnav("l") end, opts)