Skip to content

Commit

Permalink
feat(harpoon)!: make terminal keymaps dynamic based on $TMUX
Browse files Browse the repository at this point in the history
  • Loading branch information
RayJameson committed Jun 20, 2023
1 parent 3534cfc commit e77f353
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions lua/astrocommunity/motion/harpoon/harpoon.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
local prefix = "<leader><leader>"
local dynamic_tmux_keymap_desc
local running_tmux_seesion = vim.fn.exists "$TMUX" == 1
if running_tmux_seesion then
dynamic_tmux_keymap_desc = "Goto to TMUX window"
else
dynamic_tmux_keymap_desc = "Goto to terminal window"
end
return {
"ThePrimeagen/harpoon",
dependencies = {
Expand All @@ -16,20 +23,17 @@ return {
{
prefix .. "t",
function()
local num = tonumber(vim.fn.input "GoTo terminal window number: ")
if num == nil then return end
require("harpoon.term").gotoTerminal(num)
if running_tmux_seesion then
local num = tonumber(vim.fn.input "GoTo Tmux window number: ")
if num == nil then return end
require("harpoon.tmux").gotoTerminal(num)
else
local num = tonumber(vim.fn.input "GoTo terminal window number: ")
if num == nil then return end
require("harpoon.term").gotoTerminal(num)
end
end,
desc = "Goto to terminal window",
},
{
prefix .. "j",
function()
local num = tonumber(vim.fn.input "GoTo Tmux window number: ")
if num == nil then return end
require("harpoon.tmux").gotoTerminal(num)
end,
desc = "Goto to TMUX tmux window",
desc = dynamic_tmux_keymap_desc,
},
},
}

0 comments on commit e77f353

Please sign in to comment.