Skip to content

Commit

Permalink
remove unnecessary function
Browse files Browse the repository at this point in the history
  • Loading branch information
johnpgr committed Jan 12, 2024
1 parent 0a5ca50 commit c8db197
Showing 1 changed file with 3 additions and 16 deletions.
19 changes: 3 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ In order to use [Telescope](https://github.com/nvim-telescope/telescope.nvim) as
make sure to add `telescope` to your dependencies and paste this following snippet into your configuration.

```lua
local finders = require("telescope.finders")
local actions = require("telescope.actions")
local action_state = require("telescope.actions.state")
local harpoon = require('harpoon')
Expand All @@ -100,21 +101,13 @@ local function toggle_telescope(harpoon_files)

require("telescope.pickers").new({}, {
prompt_title = "Harpoon",
finder = require("telescope.finders").new_table({
finder = finders.new_table({
results = file_paths,
}),
previewer = conf.file_previewer({}),
sorter = conf.generic_sorter({}),
-- Make telescope select buffer from harpoon list
attach_mappings = function(_, map)
local function list_find(list, func)
for i, v in ipairs(list) do
if func(v, i, list) then
return i, v
end
end
end

actions.select_default:replace(function(prompt_bufnr)
local curr_picker = action_state.get_current_picker(prompt_bufnr)
local curr_entry = action_state.get_selected_entry()
Expand All @@ -123,13 +116,7 @@ local function toggle_telescope(harpoon_files)
end
actions.close(prompt_bufnr)

local idx, _ = list_find(curr_picker.finder.results, function(v)
if curr_entry.value == v.value then
return true
end
return false
end)
harpoon:list():select(idx)
harpoon:list():select(curr_entry.index)
end)
-- Delete entries from harpoon list with <C-d>
map({ 'n', 'i' }, '<C-d>', function(prompt_bufnr)
Expand Down

0 comments on commit c8db197

Please sign in to comment.