From 21474b586cc015f01c13ca94bd010925172f32be Mon Sep 17 00:00:00 2001 From: smolck <46855713+smolck@users.noreply.github.com> Date: Sun, 30 Aug 2020 12:22:21 -0500 Subject: [PATCH] Add FZF builtin for searching vim.v.oldfiles --- lua/telescope/builtin.lua | 26 ++++++++++++++++++++++++++ lua/telescope/finders.lua | 2 ++ 2 files changed, 28 insertions(+) diff --git a/lua/telescope/builtin.lua b/lua/telescope/builtin.lua index 6b6ee8e..33728b2 100644 --- a/lua/telescope/builtin.lua +++ b/lua/telescope/builtin.lua @@ -233,4 +233,30 @@ builtin.grep_string = function(opts) } end +builtin.fzf_history = function() + local history_lines = table.concat(vim.v.oldfiles, '\n') + + local fzf = finders.new { + maximum_results = 1000, + fn_command = function(self, prompt) + return { + command = 'fzf', + args = {'--no-sort', '--filter', prompt}, + + writer = { + command = 'echo', + args = {history_lines}, + } + } + end + } + + local file_picker = pickers.new { } + + file_picker:find { + prompt = 'FZF History', + finder = fzf, + } +end + return builtin diff --git a/lua/telescope/finders.lua b/lua/telescope/finders.lua index 7866c87..700d6d0 100644 --- a/lua/telescope/finders.lua +++ b/lua/telescope/finders.lua @@ -129,6 +129,8 @@ function Finder:_find(prompt, process_result, process_complete) maximum_results = self.maximum_results, + writer = opts.writer and Job:new(opts.writer) or nil, + on_stdout = on_output, on_stderr = on_output,