From 7ed2303648bf83bb081d9bd863660ebf2344ce47 Mon Sep 17 00:00:00 2001 From: srdusr Date: Wed, 24 Sep 2025 04:19:28 +0200 Subject: Squashed 'common/config/nvim/' changes from 2a8020a..966d12a 966d12a Update/Overhaul git-subtree-dir: common/config/nvim git-subtree-split: 966d12ac730c83da90d60ab24eae539b2ea69441 --- lua/plugins/harpoon.lua | 40 ++++++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 12 deletions(-) mode change 100644 => 100755 lua/plugins/harpoon.lua (limited to 'lua/plugins/harpoon.lua') diff --git a/lua/plugins/harpoon.lua b/lua/plugins/harpoon.lua old mode 100644 new mode 100755 index 784ee0b..8e842b3 --- a/lua/plugins/harpoon.lua +++ b/lua/plugins/harpoon.lua @@ -1,4 +1,12 @@ -require("harpoon").setup({ +local M = {} + +function M.setup() + local ok, harpoon = pcall(require, "harpoon") + if not ok or not harpoon then + return false + end + + harpoon.setup({ menu = { width = vim.api.nvim_win_get_width(0) - 4, }, @@ -12,18 +20,26 @@ require("harpoon").setup({ -- --{ "4", function() require("harpoon.term").gotoTerminal(2) end, desc = "Terminal 2" }, -- --{ "5", function() require("harpoon.term").sendCommand(1,1) end, desc = "Command 1" }, -- --{ "6", function() require("harpoon.term").sendCommand(1,2) end, desc = "Command 2" }, - --}, -}) -vim.api.nvim_set_keymap("n", "ma", ":lua require('harpoon.mark').add_file()", {}) -vim.api.nvim_set_keymap("n", "mt", ":lua require('harpoon.mark').toggle_file()", {}) -vim.api.nvim_set_keymap("n", "mq", ":lua require('harpoon.ui').toggle_quick_menu()", {}) -vim.api.nvim_set_keymap("n", "mh", ":lua require('harpoon.ui').nav_file(1)", {}) -vim.api.nvim_set_keymap("n", "mj", ":lua require('harpoon.ui').nav_file(2)", {}) -vim.api.nvim_set_keymap("n", "mk", ":lua require('harpoon.ui').nav_file(3)", {}) -vim.api.nvim_set_keymap("n", "ml", ":lua require('harpoon.ui').nav_file(4)", {}) + }) + + -- Set up keymaps safely + local function safe_keymap(mode, lhs, rhs, opts) + local opts_with_noremap = vim.tbl_extend('force', {noremap = true, silent = true}, opts or {}) + vim.keymap.set(mode, lhs, rhs, opts_with_noremap) + end + + safe_keymap("n", "ma", function() require('harpoon.mark').add_file() end, { desc = "Harpoon: Add file" }) + safe_keymap("n", "mt", function() require('harpoon.mark').toggle_file() end, { desc = "Harpoon: Toggle file" }) + safe_keymap("n", "mq", function() require('harpoon.ui').toggle_quick_menu() end, { desc = "Harpoon: Toggle quick menu" }) + safe_keymap("n", "mh", function() require('harpoon.ui').nav_file(1) end, { desc = "Harpoon: Navigate to file 1" }) + safe_keymap("n", "mj", function() require('harpoon.ui').nav_file(2) end, { desc = "Harpoon: Navigate to file 2" }) + safe_keymap("n", "mk", function() require('harpoon.ui').nav_file(3) end, { desc = "Harpoon: Navigate to file 3" }) + safe_keymap("n", "ml", function() require('harpoon.ui').nav_file(4) end, { desc = "Harpoon: Navigate to file 4" }) + + return true +end ---local mark = require("harpoon.mark") ---local ui = require("harpoon.ui") +return M -- --vim.keymap.set("n", "a", mark.add_file) --vim.keymap.set("n", "", ui.toggle_quick_menu) -- cgit v1.2.3