summaryrefslogtreecommitdiff
path: root/lua/telescope/make_entry.lua
diff options
context:
space:
mode:
authorSenghan Bright <senghan.bright@deltaprojects.com>2020-10-04 15:08:05 +0200
committerGitHub <noreply@github.com>2020-10-04 09:08:05 -0400
commit054bd34498e3e6cfef8f8332fe8de4c0463914dd (patch)
tree6a850906dbf3e440b527adf481c1f40320845524 /lua/telescope/make_entry.lua
parentce66c1f78c87a2dcc8cb286d5536365b54d7e3ee (diff)
feat: builtin - lua package reloader (#132)
Diffstat (limited to 'lua/telescope/make_entry.lua')
-rw-r--r--lua/telescope/make_entry.lua24
1 files changed, 24 insertions, 0 deletions
diff --git a/lua/telescope/make_entry.lua b/lua/telescope/make_entry.lua
index c62df79..8c598cd 100644
--- a/lua/telescope/make_entry.lua
+++ b/lua/telescope/make_entry.lua
@@ -331,4 +331,28 @@ function make_entry.gen_from_tagfile(opts)
end
end
+function make_entry.gen_from_packages(opts)
+ opts = opts or {}
+
+ local make_display = function(module_name)
+ local path = package.searchpath(module_name, package.path) or ""
+ local display = string.format("%-" .. opts.column_len .. "s : %s", module_name, vim.fn.fnamemodify(path, ":~:."))
+
+ return display
+ end
+
+ return function(module_name)
+ local entry = {
+ valid = module_name ~= "",
+ entry_type = make_entry.types.GENERIC,
+
+ value = module_name,
+ ordinal = module_name,
+ }
+ entry.display = make_display(module_name)
+
+ return entry
+ end
+end
+
return make_entry