wip: Messing around w/ ffi for some stuff

This commit is contained in:
TJ DeVries
2020-08-31 18:12:51 -04:00
parent e38589f265
commit 8c5bf8c746
4 changed files with 63 additions and 12 deletions

View File

@@ -40,6 +40,7 @@ function Finder:new(opts)
local obj = setmetatable({
results = opts.results,
entry_maker = opts.entry_maker,
fn_command = opts.fn_command,
static = opts.static,
state = {},
@@ -95,24 +96,18 @@ function Finder:_find(prompt, process_result, process_complete)
-- TODO: Should consider ways to allow "transformers" to be run here.
-- So that a finder can choose to "transform" the text into something much more easily usable.
local entries_processed = 0
local on_output = function(_, line, _)
if not line then
return
end
if maximum_results then
entries_processed = entries_processed + 1
if entries_processed > maximum_results then
log.info("Shutting down job early...")
self.job:shutdown()
end
end
if vim.trim(line) ~= "" then
line = line:gsub("\n", "")
if self.entry_maker then
line = self.entry_maker(line)
end
process_result(line)
if self.static then
@@ -160,7 +155,7 @@ end
-- }
-- end
finders.new_oneshot_job = function(command_list)
finders.new_oneshot_job = function(command_list, entry_maker)
command_list = vim.deepcopy(command_list)
local command = table.remove(command_list, 1)
@@ -168,6 +163,8 @@ finders.new_oneshot_job = function(command_list)
return finders.new {
static = true,
entry_maker = entry_maker,
fn_command = function()
return {
command = command,