refactor: Jumplist picker uses quickfix entry maker. Delete jumplist entry maker. (#973)
This commit is contained in:
@@ -951,15 +951,18 @@ internal.jumplist = function(opts)
|
||||
-- reverse the list
|
||||
local sorted_jumplist = {}
|
||||
for i = #jumplist, 1, -1 do
|
||||
jumplist[i].text = ''
|
||||
if vim.api.nvim_buf_is_valid(jumplist[i].bufnr) then
|
||||
jumplist[i].text = vim.api.nvim_buf_get_lines(jumplist[i].bufnr, jumplist[i].lnum, jumplist[i].lnum+1,
|
||||
false)[1] or ''
|
||||
table.insert(sorted_jumplist, jumplist[i])
|
||||
end
|
||||
end
|
||||
|
||||
pickers.new(opts, {
|
||||
prompt_title = 'Jumplist',
|
||||
finder = finders.new_table {
|
||||
results = sorted_jumplist,
|
||||
entry_maker = make_entry.gen_from_jumplist(opts),
|
||||
entry_maker = make_entry.gen_from_quickfix(opts),
|
||||
},
|
||||
previewer = conf.qflist_previewer(opts),
|
||||
sorter = conf.generic_sorter(opts),
|
||||
|
||||
@@ -1111,52 +1111,5 @@ function make_entry.gen_from_git_status(opts)
|
||||
end
|
||||
end
|
||||
|
||||
function make_entry.gen_from_jumplist(opts)
|
||||
opts = opts or {}
|
||||
|
||||
local displayer = entry_display.create {
|
||||
separator = "▏",
|
||||
items = {
|
||||
{ width = 10 },
|
||||
{ remaining = true },
|
||||
}
|
||||
}
|
||||
|
||||
local make_display = function(entry)
|
||||
local filename = utils.transform_path(opts, entry.filename)
|
||||
|
||||
local line_info = {table.concat({entry.lnum, entry.col}, ":"), "TelescopeResultsLineNr"}
|
||||
|
||||
return displayer {
|
||||
line_info,
|
||||
filename,
|
||||
}
|
||||
end
|
||||
|
||||
return function(entry)
|
||||
if not vim.api.nvim_buf_is_valid(entry.bufnr) then
|
||||
return
|
||||
end
|
||||
|
||||
local filename = entry.filename or vim.api.nvim_buf_get_name(entry.bufnr)
|
||||
|
||||
return {
|
||||
valid = true,
|
||||
|
||||
value = entry,
|
||||
ordinal = (
|
||||
not opts.ignore_filename and filename
|
||||
or ''
|
||||
) .. ' ' .. entry.text,
|
||||
display = make_display,
|
||||
|
||||
bufnr = entry.bufnr,
|
||||
filename = filename,
|
||||
lnum = entry.lnum,
|
||||
col = entry.col,
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
return make_entry
|
||||
|
||||
Reference in New Issue
Block a user