feat: Add status, better debug, and some associated refactors

* [WIP]: Mon 28 Sep 2020 01:08:24 PM EDT

* add much much better tracking. so much less hax

* status updates, oneshot job updates, etc.

* remove temp function

* add status function

* asdfasdfasdf
This commit is contained in:
TJ DeVries
2020-09-29 22:52:38 -04:00
committed by GitHub
parent 2ce23696de
commit ae7fd0d27a
22 changed files with 981 additions and 439 deletions

View File

@@ -0,0 +1,80 @@
RELOAD('telescope')
local actions = require('telescope.actions')
local finders = require('telescope.finders')
local make_entry = require('telescope.make_entry')
local previewers = require('telescope.previewers')
local pickers = require('telescope.pickers')
local sorters = require('telescope.sorters')
local utils = require('telescope.utils')
local find_files = function(opts)
opts = opts or {}
local find_command = opts.find_command
if not find_command then
if 1 == vim.fn.executable("fd") then
find_command = { 'fd', '--type', 'f' }
elseif 1 == vim.fn.executable("fdfind") then
find_command = { 'fdfind', '--type', 'f' }
elseif 1 == vim.fn.executable("rg") then
find_command = { 'rg', '--files' }
end
end
if opts.cwd then
opts.cwd = vim.fn.expand(opts.cwd)
end
opts.entry_maker = opts.entry_maker or make_entry.gen_from_file(opts)
local p = pickers.new(opts, {
prompt = 'Find Files',
finder = finders.new_oneshot_job(
find_command,
opts
),
previewer = previewers.cat.new(opts),
sorter = sorters.get_fuzzy_file(),
track = true,
})
local count = 0
p:register_completion_callback(function(s)
print(count, vim.inspect(s.stats, {
process = function(item)
if type(item) == 'string' and item:sub(1, 1) == '_' then
return nil
end
return item
end,
}))
count = count + 1
end)
local feed = function(text)
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(text, true, false, true), 'n', true)
end
p:register_completion_callback(coroutine.wrap(function()
local input = "pickers.lua"
for i = 1, #input do
feed(input:sub(i, i))
coroutine.yield()
end
vim.wait(300, function() end)
vim.cmd [[:q]]
vim.cmd [[:Messages]]
vim.cmd [[stopinsert]]
end))
p:find()
end
find_files()

View File

@@ -7,9 +7,6 @@ local previewers = require('telescope.previewers')
local pickers = require('telescope.pickers')
local sorters = require('telescope.sorters')
PERF_DEBUG = 182
vim.api.nvim_buf_set_lines(PERF_DEBUG, 0, -1, false, {})
local cwd = vim.fn.expand("~/build/neovim")
pickers.new {
@@ -28,7 +25,6 @@ pickers.new {
}:find()
COMPLETED = false
-- vim.wait(3000, function()
-- vim.cmd [[redraw!]]
-- return COMPLETED

View File

@@ -0,0 +1,71 @@
RELOAD('telescope')
local actions = require('telescope.actions')
local finders = require('telescope.finders')
local make_entry = require('telescope.make_entry')
local previewers = require('telescope.previewers')
local pickers = require('telescope.pickers')
local sorters = require('telescope.sorters')
local utils = require('telescope.utils')
local slow_proc = function(opts)
opts = opts or {}
if opts.cwd then
opts.cwd = vim.fn.expand(opts.cwd)
end
opts.entry_maker = opts.entry_maker or make_entry.gen_from_file(opts)
local p = pickers.new(opts, {
prompt = 'Slow Proc',
finder = finders.new_oneshot_job(
{"./scratch/slow_proc.sh"},
opts
),
previewer = previewers.cat.new(opts),
sorter = sorters.get_fuzzy_file(),
track = true,
})
local count = 0
p:register_completion_callback(function(s)
print(count, vim.inspect(s.stats, {
process = function(item)
if type(item) == 'string' and item:sub(1, 1) == '_' then
return nil
end
return item
end,
}))
count = count + 1
end)
local feed = function(text)
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(text, true, false, true), 'n', true)
end
if false then
p:register_completion_callback(coroutine.wrap(function()
local input = "pickers.lua"
for i = 1, #input do
feed(input:sub(i, i))
coroutine.yield()
end
vim.wait(300, function() end)
vim.cmd [[:q]]
vim.cmd [[:Messages]]
vim.cmd [[stopinsert]]
end))
end
p:find()
end
slow_proc()