From bbd51a0b85b76c62922764d9494398124771002c Mon Sep 17 00:00:00 2001 From: jaredgoldman Date: Thu, 11 Apr 2024 16:00:37 -0400 Subject: [PATCH] feat: add harpoon toggle --- lazy-lock.json | 4 +- lua/config/harpoon.lua | 1 + lua/keymaps.lua | 132 ++++++++++++++++++++--------------------- requirements.md | 5 +- 4 files changed, 72 insertions(+), 70 deletions(-) diff --git a/lazy-lock.json b/lazy-lock.json index a25b34d..80731f9 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -22,9 +22,9 @@ "nvim-comment": { "branch": "main", "commit": "e9ac16ab056695cad6461173693069ec070d2b23" }, "nvim-dap": { "branch": "master", "commit": "405df1dcc2e395ab5173a9c3d00e03942c023074" }, "nvim-grey": { "branch": "main", "commit": "e5fc8cc1e0c88c23bc6c92845f19a342f561c409" }, - "nvim-lspconfig": { "branch": "master", "commit": "e25c4cdecd3d58c0deccce0f372426c8c480bcce" }, + "nvim-lspconfig": { "branch": "master", "commit": "b3014f2209503944f2714cf27c95591433a0c7d8" }, "nvim-tree.lua": { "branch": "master", "commit": "81eb8d519233c105f30dc0a278607e62b20502fd" }, - "nvim-treesitter": { "branch": "master", "commit": "2bad828b48aed74efe8f7e4ea15550e18c7b482d" }, + "nvim-treesitter": { "branch": "master", "commit": "5c4892b0556d1258c423e2369d6a602d9b2a4988" }, "nvim-ts-autotag": { "branch": "main", "commit": "531f48334c422222aebc888fd36e7d109cb354cd" }, "nvim-web-devicons": { "branch": "master", "commit": "6e355632387a085f15a66ad68cf681c1d7374a04" }, "plenary.nvim": { "branch": "master", "commit": "8aad4396840be7fc42896e3011751b7609ca4119" }, diff --git a/lua/config/harpoon.lua b/lua/config/harpoon.lua index 2378a6d..bb4ae9c 100644 --- a/lua/config/harpoon.lua +++ b/lua/config/harpoon.lua @@ -20,6 +20,7 @@ local function toggle_telescope(harpoon_files) }) :find() end + local function toggle_mark() local current_file = api.nvim_buf_get_name(0) -- Get the current buffer's file path local item, index = harpoon:list():get_by_value(current_file) diff --git a/lua/keymaps.lua b/lua/keymaps.lua index d4bce19..09d80fe 100644 --- a/lua/keymaps.lua +++ b/lua/keymaps.lua @@ -2,73 +2,73 @@ local keymap = vim.api.nvim_set_keymap local opts = { noremap = true, silent = true } local mappings = { - n = { - -- highlighting - ["nh"] = ":nohl", - -- move between buffers - [""] = "h", - [""] = "j", - [""] = "k", - [""] = "l", - -- open and close buggers - ["sv"] = "s", - ["sh"] = "v", - ["se"] = "=", - ["sx"] = ":close", - -- nvim-tree - ["e"] = ":NvimTreeFindFileToggle", - ["cf"] = ":NvimTreeCollapse", - -- LSP - ["ls"] = ":lspstop", - ["lo"] = ":lspstart", - -- Telescope - ["ff"] = "Telescope find_files", - ["fw"] = "Telescope live_grep", - ["fc"] = "Telescope grep_string", - ["th"] = "Themery", - ["sm"] = ":MaximizerToggle", - -- FTerm - ["h"] = "FTermToggle", - -- Harpoon - ["a"] = "HarpoonToggleFile", - [""] = "HarpoonUI", - ["c"] = "HarpoonClear", - -- Formating - ["fm"] = "Format", - -- Disable help menu - [""] = "", - }, - x = { - [""] = ":move '>+1gv-gv", - [""] = ":move '<-2gv-gv", - }, - i = { - [""] = { 'copilot#Accept("")', expr = true }, - [""] = "", - ["C-BS"] = "HarpoonRemove", - -- Disable help menu - [""] = "", - }, - t = { - ["C-h"] = ":FTermClose", - }, + n = { + -- highlighting + ["nh"] = ":nohl", + -- move between buffers + [""] = "h", + [""] = "j", + [""] = "k", + [""] = "l", + -- open and close buggers + ["sv"] = "s", + ["sh"] = "v", + ["se"] = "=", + ["sx"] = ":close", + -- nvim-tree + ["e"] = ":NvimTreeFindFileToggle", + ["cf"] = ":NvimTreeCollapse", + -- LSP + ["ls"] = ":lspstop", + ["lo"] = ":lspstart", + -- Telescope + ["ff"] = "Telescope find_files", + ["fw"] = "Telescope live_grep", + ["fc"] = "Telescope grep_string", + ["th"] = "Themery", + ["sm"] = ":MaximizerToggle", + -- FTerm + ["h"] = "FTermToggle", + -- Harpoon + ["a"] = "HarpoonToggleFile", + [""] = "HarpoonUI", + ["c"] = "HarpoonClear", + -- Formating + ["fm"] = "Format", + -- Disable help menu + [""] = "", + }, + x = { + [""] = ":move '>+1gv-gv", + [""] = ":move '<-2gv-gv", + }, + i = { + [""] = { 'copilot#Accept("")', expr = true }, + [""] = "", + ["C-BS"] = "HarpoonRemove", + -- Disable help menu + [""] = "", + }, + t = { + ["C-h"] = ":FTermClose", + }, } for mode, mode_mappings in pairs(mappings) do - for key, mapping in pairs(mode_mappings) do - if type(mapping) == "function" then - -- For direct Lua function calls; ensure your function returns a string command - keymap(mode, key, "lua " .. mapping() .. "", opts) - elseif type(mapping) == "table" and mapping.expr then - -- For expression mappings, like for copilot - local expr_opts = vim.tbl_extend("force", opts, { expr = true }) - keymap(mode, key, mapping[1], expr_opts) - elseif type(mapping) == "table" then - -- For mappings that have their options specified directly - keymap(mode, key, mapping[1], mapping[2] or opts) - else - -- For simple string command mappings - keymap(mode, key, mapping, opts) - end - end + for key, mapping in pairs(mode_mappings) do + if type(mapping) == "function" then + -- For direct Lua function calls; ensure your function returns a string command + keymap(mode, key, "lua " .. mapping() .. "", opts) + elseif type(mapping) == "table" and mapping.expr then + -- For expression mappings, like for copilot + local expr_opts = vim.tbl_extend("force", opts, { expr = true }) + keymap(mode, key, mapping[1], expr_opts) + elseif type(mapping) == "table" then + -- For mappings that have their options specified directly + keymap(mode, key, mapping[1], mapping[2] or opts) + else + -- For simple string command mappings + keymap(mode, key, mapping, opts) + end + end end diff --git a/requirements.md b/requirements.md index 25f08d2..45c8bb4 100644 --- a/requirements.md +++ b/requirements.md @@ -1,10 +1,11 @@ # Requirements for my setup + - file tree x - lsp with mason x - telescope x - theming x - tabfluline x - - rice x + - rice x - terminal x - harpoon x - extended history x @@ -12,5 +13,5 @@ - lua vim linting x - dashboard x - suppress vim global warnings x -- harpoon toggle file +- harpoon toggle file x - debugger