summaryrefslogtreecommitdiff
path: root/lua/telescope/make_entry.lua
diff options
context:
space:
mode:
authorcaojoshua <33404808+caojoshua@users.noreply.github.com>2021-05-09 02:05:12 -0700
committerGitHub <noreply@github.com>2021-05-09 11:05:12 +0200
commite2907fc0f225a7bf33ace6915bc6b55ed1e10b31 (patch)
tree58a373535adf3d13947965e6a0b2f16f06737d52 /lua/telescope/make_entry.lua
parent25a7ecc289dffaa3d45870b452fa1bfb83253ba9 (diff)
feat: jumplist picker and jump to row/col on existing buffers. (#813)
Diffstat (limited to 'lua/telescope/make_entry.lua')
-rw-r--r--lua/telescope/make_entry.lua56
1 files changed, 56 insertions, 0 deletions
diff --git a/lua/telescope/make_entry.lua b/lua/telescope/make_entry.lua
index 01d0062..9435354 100644
--- a/lua/telescope/make_entry.lua
+++ b/lua/telescope/make_entry.lua
@@ -1139,5 +1139,61 @@ function make_entry.gen_from_git_status(opts)
end
end
+function make_entry.gen_from_jumplist(opts)
+ opts = opts or {}
+ opts.tail_path = get_default(opts.tail_path, true)
+
+ local displayer = entry_display.create {
+ separator = "▏",
+ items = {
+ { width = 10 },
+ { remaining = true },
+ }
+ }
+
+ local make_display = function(entry)
+ local filename
+ if not opts.hide_filename then
+ filename = entry.filename
+ if opts.tail_path then
+ filename = utils.path_tail(filename)
+ elseif opts.shorten_path then
+ filename = utils.path_shorten(filename)
+ end
+ end
+
+ 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