forked from nvim-lua/kickstart.nvim
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathharpoon.lua
More file actions
64 lines (58 loc) · 1.76 KB
/
harpoon.lua
File metadata and controls
64 lines (58 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
return {
'ThePrimeagen/harpoon',
branch = 'harpoon2',
commit = 'e76cb03',
dependencies = { 'nvim-lua/plenary.nvim' },
config = function()
local harpoon = require 'harpoon'
harpoon:setup {
settings = {
save_on_toggle = true,
mark_branch = true,
},
}
-- basic telescope configuration
local conf = require('telescope.config').values
local function toggle_telescope(harpoon_files)
local file_paths = {}
for _, item in ipairs(harpoon_files.items) do
table.insert(file_paths, item.value)
end
require('telescope.pickers')
.new({}, {
prompt_title = 'Harpoon',
finder = require('telescope.finders').new_table {
results = file_paths,
},
previewer = conf.file_previewer {},
sorter = conf.generic_sorter {},
})
:find()
end
vim.keymap.set('n', '<C-h>', function()
toggle_telescope(harpoon:list())
end, { desc = 'Open harpoon window' })
vim.keymap.set('n', '<leader>ha', function()
harpoon:list():add()
end, { desc = '[H]arpoon [A]dd mark' })
vim.keymap.set('n', '<C-1>', function()
harpoon:list():select(1)
end)
vim.keymap.set('n', '<C-2>', function()
harpoon:list():select(2)
end)
vim.keymap.set('n', '<C-3>', function()
harpoon:list():select(3)
end)
vim.keymap.set('n', '<C-4>', function()
harpoon:list():select(4)
end)
-- Toggle previous & next buffers stored within Harpoon list
vim.keymap.set('n', '<leader>hp', function()
harpoon:list():prev()
end, { desc = '[H]arpoon [P]rev item' })
vim.keymap.set('n', '<leader>hn', function()
harpoon:list():next()
end, { desc = '[H]arpoon [N]ext item' })
end,
}