Add FZF builtin for searching vim.v.oldfiles

This commit is contained in:
smolck
2020-08-30 12:22:21 -05:00
committed by TJ DeVries
parent 2ba8d57d78
commit 21474b586c
2 changed files with 28 additions and 0 deletions

View File

@@ -233,4 +233,30 @@ builtin.grep_string = function(opts)
} }
end 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 return builtin

View File

@@ -129,6 +129,8 @@ function Finder:_find(prompt, process_result, process_complete)
maximum_results = self.maximum_results, maximum_results = self.maximum_results,
writer = opts.writer and Job:new(opts.writer) or nil,
on_stdout = on_output, on_stdout = on_output,
on_stderr = on_output, on_stderr = on_output,