From 39096492aba5e2fe8a8c0bc11a040a90bb95280b Mon Sep 17 00:00:00 2001 From: TJ DeVries Date: Tue, 1 Sep 2020 22:27:50 -0400 Subject: feat/hack: Add builtin.builtin --- lua/telescope/builtin.lua | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) (limited to 'lua/telescope/builtin.lua') diff --git a/lua/telescope/builtin.lua b/lua/telescope/builtin.lua index f6b665e..2c59b14 100644 --- a/lua/telescope/builtin.lua +++ b/lua/telescope/builtin.lua @@ -152,7 +152,7 @@ builtin.oldfiles = function(opts) finder = finders.new_table(vim.tbl_filter(function(val) return 0 ~= vim.fn.filereadable(val) end, vim.v.oldfiles)), - sorter = sorters.get_norcalli_sorter(), + sorter = sorters.get_fuzzy_file(), previewer = previewers.cat, }):find() end @@ -178,4 +178,34 @@ builtin.command_history = function(opts) }):find() end +-- TODO: What the heck should we do for accepting this. +-- vim.fn.setreg("+", "nnoremap $TODO :lua require('telescope.builtin').()") +-- TODO: Can we just do the names instead? +builtin.builtin = function(opts) + local objs = {} + + for k, v in pairs(builtin) do + local debug_info = debug.getinfo(v) + + table.insert(objs, { + vimgrep_str = k, + filename = string.sub(debug_info.source, 2), + lnum = debug_info.linedefined, + col = 0, + + start = debug_info.linedefined, + finish = debug_info.lastlinedefined, + }) + end + + local entries = utils.quickfix_items_to_entries(objs) + + pickers.new(opts, { + prompt = 'Telescope Builtin', + finder = finders.new_table(entries), + previewer = previewers.qflist, + sorter = sorters.get_norcalli_sorter(), + }):find() +end + return builtin -- cgit v1.2.3