feat: asyncify pickers - except for live_grep (#709)

* something kind of works already

* yayayayayayayayayayayayayayayayayayayayayayayayayayayayayayayayaya

* use async for everything besides live jobs

* fix: fixup autocmds previewer

* fix: lints for prime

* temp: Add example of how we can think about async sorters

* feat: Allow picker to decide when to cancel

* fix: simplify scoring logic and tests

* fixup: name

* fix: Move back towards more backwards compat methods

* fixup: Remove results from opts

* fixup: remove trailing quote

* fixup: Attempt to clean up some more async items. Next is status

* wip: Add todo for when bfredl implements extmarks over the EOL

* wip

* fixup: got em

* fixup: cleaning

* fixup: docs
This commit is contained in:
TJ DeVries
2021-04-08 10:35:44 -04:00
committed by GitHub
parent e5fbe6fe60
commit 64e59060b1
14 changed files with 427 additions and 366 deletions

View File

@@ -211,16 +211,16 @@ end
files.file_browser = function(opts)
opts = opts or {}
opts.depth = opts.depth or 1
opts.cwd = opts.cwd and vim.fn.expand(opts.cwd) or vim.loop.cwd()
local gen_new_finder = function(path)
opts.new_finder = opts.new_finder or function(path)
opts.cwd = path
local data = {}
scan.scan_dir(path, {
hidden = opts.hidden or false,
add_dirs = true,
depth = 1,
depth = opts.depth,
on_insert = function(entry, typ)
table.insert(data, typ == 'directory' and (entry .. os_sep) or entry)
end
@@ -242,8 +242,8 @@ files.file_browser = function(opts)
end
pickers.new(opts, {
prompt_title = 'Find Files',
finder = gen_new_finder(opts.cwd),
prompt_title = 'File Browser',
finder = opts.new_finder(opts.cwd),
previewer = conf.file_previewer(opts),
sorter = conf.file_sorter(opts),
attach_mappings = function(prompt_bufnr, map)
@@ -253,7 +253,7 @@ files.file_browser = function(opts)
local new_cwd = vim.fn.expand(action_state.get_selected_entry().path:sub(1, -2))
local current_picker = action_state.get_current_picker(prompt_bufnr)
current_picker.cwd = new_cwd
current_picker:refresh(gen_new_finder(new_cwd), { reset_prompt = true })
current_picker:refresh(opts.new_finder(new_cwd), { reset_prompt = true })
end)
local create_new_file = function()
@@ -276,7 +276,7 @@ files.file_browser = function(opts)
Path:new(fpath:sub(1, -2)):mkdir({ parents = true })
local new_cwd = vim.fn.expand(fpath)
current_picker.cwd = new_cwd
current_picker:refresh(gen_new_finder(new_cwd), { reset_prompt = true })
current_picker:refresh(opts.new_finder(new_cwd), { reset_prompt = true })
end
end