Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(harpoon)!: remove "j" keymap, make "t" keymap dynamic based on $TMUX #292

Merged
merged 5 commits into from
Jun 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 23 additions & 12 deletions lua/astrocommunity/motion/harpoon/init.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
local prefix = "<leader><leader>"
local running_tmux_session = vim.fn.exists "$TMUX" == 1
local dynamic_tmux_keymap_desc = "Go to " .. running_tmux_session and "TMUX" or "terminal" .. " window"
local icon = vim.g.icons_enabled and "󱡀 " or ""
return {
"ThePrimeagen/harpoon",
dependencies = {
Expand All @@ -7,27 +10,35 @@ return {
},
cmd = { "Harpoon" },
keys = {
{ prefix, desc = "Harpoon" },
{ prefix, function() end, desc = icon .. "Harpoon" },
{ prefix .. "a", function() require("harpoon.mark").add_file() end, desc = "Add file" },
{ prefix .. "e", function() require("harpoon.ui").toggle_quick_menu() end, desc = "Toggle quick menu" },
{ "<C-p>", function() require("harpoon.ui").nav_prev() end, desc = "Goto previous mark" },
{ "<C-n>", function() require("harpoon.ui").nav_next() end, desc = "Goto next mark" },
{ prefix .. "m", "<cmd>Telescope harpoon marks<CR>", desc = "Show marks in Telescope" },
{
prefix .. "t",
"<C-t>",
function()
local num = tonumber(vim.fn.input "GoTo terminal window number: ")
require("harpoon.term").gotoTerminal(num)
local num = tonumber(vim.fn.input "Go to mark index: ")
if num == nil then return end
require("harpoon.ui").nav_file(num)
end,
desc = "Goto to terminal window",
desc = "Goto index of mark",
},
{ "<C-p>", function() require("harpoon.ui").nav_prev() end, desc = "Goto previous mark" },
{ "<C-n>", function() require("harpoon.ui").nav_next() end, desc = "Goto next mark" },
{ prefix .. "m", "<cmd>Telescope harpoon marks<CR>", desc = "Show marks in Telescope" },
{
prefix .. "j",
prefix .. "t",
function()
local num = tonumber(vim.fn.input "GoTo Tmux window number: ")
require("harpoon.tmux").gotoTerminal(num)
if running_tmux_session 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 TMUX tmux window",
desc = dynamic_tmux_keymap_desc,
},
},
}