Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add "list" finder #408

Merged
merged 7 commits into from
Sep 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions bin/benchmarks/scanner.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,18 @@ benchmark({

setup = function(config)
collectgarbage()
local scanner = require(config.source)
local scanner = nil
if config.stub then
-- For scanners that otherwise depend on Neovim for a list of candidates.
config.stub()
end
if type(config.source) == 'string' then
scanner = require(config.source)
elseif type(config.source) == 'function' then
scanner = config.source()
else
error('`source` should be a string or function')
end
if scanner.name == 'watchman' then
-- We don't have a real JSON parser here, so we fake it.
local fallback = '/opt/homebrew/var/run/watchman/wincent-state/sock'
Expand All @@ -30,10 +41,6 @@ benchmark({
local name = output:match('"sockname":%s*"([^"]+)"') or fallback
scanner.set_sockname(name)
end
if config.stub then
-- For scanners that otherwise depend on Neovim for a list of candidates.
config.stub(scanner)
end
return scanner
end,

Expand Down
62 changes: 58 additions & 4 deletions data/wincent/commandt/benchmark/configs/scanner.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,15 @@ return {
variants = {
{
name = 'buffer',
source = 'wincent.commandt.private.scanners.buffer',
source = function()
local command = require('wincent.commandt').default_options().finders.buffer.candidates()
local scanner = require('wincent.commandt.private.scanners.list').scanner
return {
scanner = function()
return scanner(command)
end,
}
end,
times = times * 100, -- Scanner is too fast (misleadingly fast).
skip_in_ci = false,
stub = function()
Expand Down Expand Up @@ -203,19 +211,65 @@ return {
},
{
name = 'find',
source = 'wincent.commandt.private.scanners.find',
source = function()
local command = require('wincent.commandt').default_options().finders.find.command('')
local scanner = require('wincent.commandt.private.scanners.command').scanner
return {
scanner = function()
return scanner(command)
end,
}
end,
stub = function()
assert(_G.vim == nil)
_G.vim = {
startswith = function()
return false
end,
}
end,
unstub = function()
_G.vim = nil
end,
times = times,
skip_in_ci = false,
},
{
name = 'git',
source = 'wincent.commandt.private.scanners.git',
source = function()
local command = require('wincent.commandt').default_options().finders.git.command('', {})
local scanner = require('wincent.commandt.private.scanners.command').scanner
return {
scanner = function()
return scanner(command)
end,
}
end,
times = times,
skip_in_ci = false,
},
{
name = 'rg',
source = 'wincent.commandt.private.scanners.rg',
source = function()
local command = require('wincent.commandt').default_options().finders.rg.command('')
local scanner = require('wincent.commandt.private.scanners.command').scanner
return {
scanner = function()
return scanner(command)
end,
}
end,
stub = function()
assert(_G.vim == nil)
_G.vim = {
startswith = function()
return false
end,
}
end,
unstub = function()
_G.vim = nil
end,
times = times,
skip_in_ci = true,
},
Expand Down
3 changes: 2 additions & 1 deletion doc/command-t.txt
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,8 @@ HISTORY *command-t-history*

main (not yet released) ~

- ...
- feat: add back |:CommandTLine| finder
(https://github.com/wincent/command-t/pull/408).

6.0.0-a.4 (5 September 2022) ~

Expand Down
Loading