feat: add a bit better writer support
This commit is contained in:
@@ -53,6 +53,7 @@ function JobFinder:new(opts)
|
|||||||
state = {},
|
state = {},
|
||||||
|
|
||||||
cwd = opts.cwd,
|
cwd = opts.cwd,
|
||||||
|
writer = opts.writer,
|
||||||
|
|
||||||
-- Maximum number of results to process.
|
-- Maximum number of results to process.
|
||||||
-- Particularly useful for live updating large queries.
|
-- Particularly useful for live updating large queries.
|
||||||
@@ -114,6 +115,14 @@ function JobFinder:_find(prompt, process_result, process_complete)
|
|||||||
local opts = self:fn_command(prompt)
|
local opts = self:fn_command(prompt)
|
||||||
if not opts then return end
|
if not opts then return end
|
||||||
|
|
||||||
|
local writer = nil
|
||||||
|
if opts.writer and Job.is_job(opts.writer) then
|
||||||
|
print("WOW A JOB")
|
||||||
|
writer = opts.writer
|
||||||
|
elseif opts.writer then
|
||||||
|
writer = Job:new(opts.writer)
|
||||||
|
end
|
||||||
|
|
||||||
self.job = Job:new {
|
self.job = Job:new {
|
||||||
command = opts.command,
|
command = opts.command,
|
||||||
args = opts.args,
|
args = opts.args,
|
||||||
@@ -121,7 +130,7 @@ function JobFinder:_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,
|
writer = writer,
|
||||||
|
|
||||||
on_stdout = on_output,
|
on_stdout = on_output,
|
||||||
on_stderr = on_output,
|
on_stderr = on_output,
|
||||||
|
|||||||
@@ -4,18 +4,12 @@ local finders = require('telescope.finders')
|
|||||||
local pickers = require('telescope.pickers')
|
local pickers = require('telescope.pickers')
|
||||||
local sorters = require('telescope.sorters')
|
local sorters = require('telescope.sorters')
|
||||||
|
|
||||||
|
local my_list = {'a', 'b', 'c'}
|
||||||
|
|
||||||
pickers.new({
|
pickers.new({
|
||||||
prompt = 'Telescope Builtin',
|
prompt = 'Telescope Builtin',
|
||||||
finder = finders.new_table {
|
finder = finders.new_table {
|
||||||
results = {"hello\nworld", "other", "item"},
|
results = my_list,
|
||||||
entry_maker = false and function(line)
|
|
||||||
return {
|
|
||||||
value = line,
|
|
||||||
ordinal = line,
|
|
||||||
display = "wow: // " .. line,
|
|
||||||
}
|
|
||||||
end,
|
|
||||||
},
|
},
|
||||||
sorter = sorters.get_norcalli_sorter(),
|
sorter = sorters.get_generic_fuzzy_sorter(),
|
||||||
}):find()
|
}):find()
|
||||||
|
|||||||
Reference in New Issue
Block a user