mirror of
https://github.com/ThePrimeagen/harpoon.git
synced 2025-07-14 01:50:27 +00:00
initial telescope extension
This commit is contained in:
parent
57819752e6
commit
0a367e1f4a
11
lua/telescope/_extensions/harpoon.lua
Normal file
11
lua/telescope/_extensions/harpoon.lua
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
local has_telescope, telescope = pcall(require, "telescope")
|
||||||
|
|
||||||
|
if not has_telescope then
|
||||||
|
error("harpoon.nvim requires nvim-telescope/telescope.nvim")
|
||||||
|
end
|
||||||
|
|
||||||
|
return telescope.register_extension({
|
||||||
|
exports = {
|
||||||
|
marks = require("telescope._extensions.marks"),
|
||||||
|
},
|
||||||
|
})
|
45
lua/telescope/_extensions/marks.lua
Normal file
45
lua/telescope/_extensions/marks.lua
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
local finders = require("telescope.finders")
|
||||||
|
local make_entry = require("telescope.make_entry")
|
||||||
|
local pickers = require("telescope.pickers")
|
||||||
|
local previewers = require("telescope.previewers")
|
||||||
|
local sorters = require("telescope.sorters")
|
||||||
|
local harpoon = require("harpoon")
|
||||||
|
local entry_display = require("telescope.pickers.entry_display")
|
||||||
|
|
||||||
|
return function(opts)
|
||||||
|
opts = opts or {}
|
||||||
|
|
||||||
|
pickers.new(opts, {
|
||||||
|
prompt_title = "harpoon marks",
|
||||||
|
finder = finders.new_table({
|
||||||
|
results = harpoon.get_mark_config().marks,
|
||||||
|
entry_maker = function(mark)
|
||||||
|
local displayer = entry_display.create({
|
||||||
|
separator = " - ",
|
||||||
|
items = {
|
||||||
|
{ width = 2 },
|
||||||
|
{ width = 50 },
|
||||||
|
{ remaining = true },
|
||||||
|
},
|
||||||
|
})
|
||||||
|
local make_display = function(entry)
|
||||||
|
return displayer({
|
||||||
|
tostring(entry.index),
|
||||||
|
mark.filename,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
local line = mark.filename .. ":" .. mark.row .. ":" .. mark.col
|
||||||
|
return {
|
||||||
|
value = mark,
|
||||||
|
ordinal = line,
|
||||||
|
display = make_display,
|
||||||
|
lnum = mark.row,
|
||||||
|
col = mark.col,
|
||||||
|
filename = mark.filename,
|
||||||
|
}
|
||||||
|
end,
|
||||||
|
}),
|
||||||
|
sorter = sorters.get_fuzzy_file(),
|
||||||
|
previewer = previewers.vim_buffer_cat.new({}),
|
||||||
|
}):find()
|
||||||
|
end
|
Loading…
x
Reference in New Issue
Block a user