From e77f3536d0588747303740ba61c72487f9775ee9 Mon Sep 17 00:00:00 2001 From: Ray Jameson <67468725+RayJameson@users.noreply.github.com> Date: Tue, 20 Jun 2023 23:11:18 +0600 Subject: [PATCH] feat(harpoon)!: make terminal keymaps dynamic based on $TMUX --- lua/astrocommunity/motion/harpoon/harpoon.lua | 30 +++++++++++-------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/lua/astrocommunity/motion/harpoon/harpoon.lua b/lua/astrocommunity/motion/harpoon/harpoon.lua index 36aba6be2..b5b972cc8 100644 --- a/lua/astrocommunity/motion/harpoon/harpoon.lua +++ b/lua/astrocommunity/motion/harpoon/harpoon.lua @@ -1,4 +1,11 @@ local prefix = "" +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 = { @@ -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, }, }, }