summaryrefslogtreecommitdiffstats
path: root/lua/core
diff options
context:
space:
mode:
authorSquibid <me@zacharyscheiman.com>2024-03-09 00:02:02 -0500
committerSquibid <me@zacharyscheiman.com>2024-03-09 00:02:02 -0500
commitdebeca659ae2e41ca3f248a5ee30dbbaca6aebc8 (patch)
treeb742b75fa35ff939062e25b7a8eb185744137084 /lua/core
parent6deb1b6a6bd72319db2845a53450a6039c613954 (diff)
downloadnvim-debeca659ae2e41ca3f248a5ee30dbbaca6aebc8.tar.gz
nvim-debeca659ae2e41ca3f248a5ee30dbbaca6aebc8.tar.bz2
nvim-debeca659ae2e41ca3f248a5ee30dbbaca6aebc8.zip
update harpoon to harpoon 2
Diffstat (limited to 'lua/core')
-rw-r--r--lua/core/harpoon.lua57
1 files changed, 57 insertions, 0 deletions
diff --git a/lua/core/harpoon.lua b/lua/core/harpoon.lua
new file mode 100644
index 0000000..4d20828
--- /dev/null
+++ b/lua/core/harpoon.lua
@@ -0,0 +1,57 @@
+local pickers = require("telescope.pickers")
+local finders = require("telescope.finders")
+local conf = require("telescope.config").values
+local actions = require("telescope.actions")
+local action_set = require("telescope.actions.set")
+local action_state = require("telescope.actions.state")
+local harpoon = require('harpoon')
+
+local M = {}
+
+function M.switcher()
+ local filepaths = {}
+ for _, item in ipairs(harpoon:list().items) do
+ table.insert(filepaths, item.value)
+ end
+
+ pickers.new({
+ prompt_title = "Harpoon",
+ finder = finders.new_table { results = filepaths },
+ sorter = conf.generic_sorter(),
+ previewer = conf.file_previewer {},
+ attach_mappings = function(prompt_bufnr, map)
+ actions.move_selection_previous:replace(function()
+ action_set.shift_selection(prompt_bufnr, -1)
+ end)
+ actions.move_selection_next:replace(function()
+ action_set.shift_selection(prompt_bufnr, 1)
+ end)
+
+ -- remove harpoon item
+ -- TODO:
+
+ -- select items, and open buffer
+ vim.keymap.set("n", "<C-v>", function()
+ if action_state.get_selected_entry() then
+ actions.close(prompt_bufnr)
+ vim.cmd("vsplit "..action_state.get_selected_entry()[1])
+ end
+ end)
+ vim.keymap.set({ "n", "i" }, "<C-s>", function()
+ if action_state.get_selected_entry() then
+ actions.close(prompt_bufnr)
+ vim.cmd("split "..action_state.get_selected_entry()[1])
+ end
+ end)
+ actions.select_default:replace(function()
+ if action_state.get_selected_entry() then
+ actions.close(prompt_bufnr)
+ vim.cmd("e "..action_state.get_selected_entry()[1])
+ end
+ end)
+ return true
+ end
+ }):find()
+end
+
+return M