From 023e6c8baf2410da606440a9e2e8002d92fd3815 Mon Sep 17 00:00:00 2001 From: name_snrl Date: Mon, 11 Dec 2023 14:20:11 +0500 Subject: [PATCH 1/4] fix: in UI:select_menu_item close the menu first --- lua/harpoon/ui.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lua/harpoon/ui.lua b/lua/harpoon/ui.lua index aa16521..02b2fb5 100644 --- a/lua/harpoon/ui.lua +++ b/lua/harpoon/ui.lua @@ -168,8 +168,9 @@ function HarpoonUI:select_menu_item(options) options ) - self.active_list:select(idx, options) + list = self.active_list self:close_menu() + list:select(idx, options) end function HarpoonUI:save() From 747169f07ae7b3b80ae0d655458265822788ac4f Mon Sep 17 00:00:00 2001 From: Hugh Carroll Date: Sun, 17 Dec 2023 07:02:51 +0000 Subject: [PATCH 2/4] Add tabedit to split and vsplit plus a little refactor. --- lua/harpoon/config.lua | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lua/harpoon/config.lua b/lua/harpoon/config.lua index b6b61cf..f16268b 100644 --- a/lua/harpoon/config.lua +++ b/lua/harpoon/config.lua @@ -10,7 +10,7 @@ M.DEFAULT_LIST = DEFAULT_LIST ---@alias HarpoonListItem {value: any, context: any} ---@alias HarpoonListFileItem {value: string, context: {row: number, col: number}} ----@alias HarpoonListFileOptions {split: boolean, vsplit: boolean} +---@alias HarpoonListFileOptions {split: boolean, vsplit: boolean, tabedit: boolean} ---@class HarpoonPartialConfigItem ---@field select_with_nil? boolean defaults to false @@ -115,14 +115,15 @@ function M.get_default_config() if options.vsplit then vim.cmd("vsplit") - vim.api.nvim_set_current_buf(bufnr) elseif options.split then vim.cmd("split") - vim.api.nvim_set_current_buf(bufnr) - else - vim.api.nvim_set_current_buf(bufnr) + elseif options.tabedit then + vim.cmd("tabedit") end + vim.api.nvim_set_current_buf(bufnr) + + if set_position then vim.api.nvim_win_set_cursor(0, { list_item.context.row or 1, From c57cb1995153cd13cc62386d2bd66c84762f7d81 Mon Sep 17 00:00:00 2001 From: Hugh Carroll Date: Sun, 17 Dec 2023 07:14:34 +0000 Subject: [PATCH 3/4] Some explanation on how to configure splits & tabs. --- README.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/README.md b/README.md index 167fe1b..92b67c6 100644 --- a/README.md +++ b/README.md @@ -192,6 +192,27 @@ settings = { }, ``` +### Extend +The 'extend' functionality can be used to add keymaps for opening files in splits & tabs. + +```lua +harpoon:extend({ + UI_CREATE = function(cx) + vim.keymap.set("n", "", function() + harpoon.ui:select_menu_item({ vsplit = true }) + end, { buffer = cx.bufnr }) + + vim.keymap.set("n", "", function() + harpoon.ui:select_menu_item({ split = true }) + end, { buffer = cx.bufnr }) + + vim.keymap.set("n", "", function() + harpoon.ui:select_menu_item({ tabedit = true }) + end, { buffer = cx.bufnr }) + end, +}) +``` + ### Highlight Groups TODO: Fill in the idea that we will emit out window information From 2036830e378fe89045085192865df883acde5856 Mon Sep 17 00:00:00 2001 From: Hugh Carroll Date: Sun, 17 Dec 2023 07:20:38 +0000 Subject: [PATCH 4/4] Remove extra blank line. --- lua/harpoon/config.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/lua/harpoon/config.lua b/lua/harpoon/config.lua index f16268b..e47a7b5 100644 --- a/lua/harpoon/config.lua +++ b/lua/harpoon/config.lua @@ -123,7 +123,6 @@ function M.get_default_config() vim.api.nvim_set_current_buf(bufnr) - if set_position then vim.api.nvim_win_set_cursor(0, { list_item.context.row or 1,