chore: use stylua for formatting (#1040)

* chore: stylua job and config

* reformat with stylua
This commit is contained in:
Simon Hauser
2021-07-23 17:42:37 +02:00
committed by GitHub
parent 664690029f
commit 79644ab677
75 changed files with 3201 additions and 2809 deletions

View File

@@ -2,19 +2,21 @@
vim.api.nvim_buf_set_lines(0, 4, -1, false, vim.tbl_keys(require('telescope.builtin')))
--]]
require('telescope.builtin').git_files()
RELOAD('telescope'); require('telescope.builtin').oldfiles()
require('telescope.builtin').grep_string()
require('telescope.builtin').lsp_document_symbols()
RELOAD('telescope'); require('telescope.builtin').lsp_workspace_symbols()
require('telescope.builtin').lsp_references()
require('telescope.builtin').builtin()
require('telescope.builtin').fd()
require('telescope.builtin').command_history()
require('telescope.builtin').search_history()
require('telescope.builtin').live_grep()
require('telescope.builtin').loclist()
require("telescope.builtin").git_files()
RELOAD "telescope"
require("telescope.builtin").oldfiles()
require("telescope.builtin").grep_string()
require("telescope.builtin").lsp_document_symbols()
RELOAD "telescope"
require("telescope.builtin").lsp_workspace_symbols()
require("telescope.builtin").lsp_references()
require("telescope.builtin").builtin()
require("telescope.builtin").fd()
require("telescope.builtin").command_history()
require("telescope.builtin").search_history()
require("telescope.builtin").live_grep()
require("telescope.builtin").loclist()
-- TODO: make a function that puts stuff into quickfix.
-- that way we can test this better.
require('telescope.builtin').quickfix()
require("telescope.builtin").quickfix()

View File

@@ -1,24 +1,24 @@
RELOAD('telescope')
RELOAD "telescope"
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 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 find_files = function(opts)
opts = opts or {}
opts.prompt_prefix = ''
opts.prompt_prefix = ""
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' }
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
@@ -29,11 +29,8 @@ local find_files = function(opts)
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
),
prompt = "Find Files",
finder = finders.new_oneshot_job(find_command, opts),
previewer = previewers.cat.new(opts),
sorter = sorters.get_fuzzy_file(),
@@ -42,21 +39,24 @@ local find_files = function(opts)
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
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,
}))
return item
end,
})
)
count = count + 1
end)
local feed = function(text, feed_opts)
feed_opts = feed_opts or 'n'
feed_opts = feed_opts or "n"
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(text, true, false, true), feed_opts, true)
end
@@ -68,10 +68,10 @@ local find_files = function(opts)
end
vim.wait(300, function() end)
feed("<CR>", '')
feed("<CR>", "")
coroutine.yield()
print("STILL CALLED?")
print "STILL CALLED?"
end))
p:find()

View File

@@ -1,5 +1,5 @@
require('plenary.reload').reload_module('plenary')
require('plenary.reload').reload_module('telescope')
require("plenary.reload").reload_module "plenary"
require("plenary.reload").reload_module "telescope"
--[[
@@ -8,11 +8,11 @@ Goals:
--]]
local finders = require('telescope.finders')
local make_entry = require('telescope.make_entry')
local pickers = require('telescope.pickers')
local sorters = require('telescope.sorters')
local EntryManager = require('telescope.entry_manager')
local finders = require "telescope.finders"
local make_entry = require "telescope.make_entry"
local pickers = require "telescope.pickers"
local sorters = require "telescope.sorters"
local EntryManager = require "telescope.entry_manager"
local find_and_sort_test = function(prompt, f, s)
local info = {}
@@ -42,10 +42,7 @@ local find_and_sort_test = function(prompt, f, s)
end
info.added = info.added + 1
entry_manager:add_entry(
s:score(prompt, entry),
entry
)
entry_manager:add_entry(s:score(prompt, entry), entry)
end
local process_complete = function()
@@ -58,7 +55,9 @@ local find_and_sort_test = function(prompt, f, s)
f(prompt, process_result, process_complete)
-- Wait until we're done to return
vim.wait(5000, function() return completed end, 10)
vim.wait(5000, function()
return completed
end, 10)
return entry_manager, info
end
@@ -74,42 +73,33 @@ local info_to_csv = function(info, filename)
writer:write(info.inserted .. "\t")
writer:write(info.total .. "\t")
writer:write(info.set_entry .. "\t")
writer:write(string.format("%.0f", collectgarbage("count")) .. "\t")
writer:write("\n")
writer:write(string.format("%.0f", collectgarbage "count") .. "\t")
writer:write "\n"
writer:close()
end
local cwd = vim.fn.expand "~/build/neovim"
local cwd = vim.fn.expand("~/build/neovim")
collectgarbage("collect")
collectgarbage "collect"
for _ = 1, 1 do
-- local s = sorters.get_fuzzy_file()
local s = sorters.get_generic_fuzzy_sorter()
local finder = finders.new_oneshot_job(
{"fdfind"},
{
cwd = cwd,
entry_maker = make_entry.gen_from_file {cwd = cwd},
-- disable_devicons = true,
-- maximum_results = 1000,
}
)
local finder = finders.new_oneshot_job({ "fdfind" }, {
cwd = cwd,
entry_maker = make_entry.gen_from_file { cwd = cwd },
-- disable_devicons = true,
-- maximum_results = 1000,
})
local res, info = find_and_sort_test(
"pickers.lua",
finder,
s
)
local res, info = find_and_sort_test("pickers.lua", finder, s)
-- print(vim.inspect(res:get_entry(1)))
-- print(vim.inspect(info))
info_to_csv(info, "/home/tj/tmp/profile.csv")
collectgarbage("collect")
collectgarbage "collect"
end
-- No skip: 2,206,186
-- Ya skip: 2,133

View File

@@ -1,29 +1,25 @@
RELOAD('plenary')
RELOAD('telescope')
RELOAD "plenary"
RELOAD "telescope"
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 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 cwd = vim.fn.expand("~/build/neovim")
local cwd = vim.fn.expand "~/build/neovim"
pickers.new {
prompt = 'Large search',
finder = finders.new_oneshot_job(
{"fdfind"},
{
cwd = cwd,
entry_maker = make_entry.gen_from_file {cwd = cwd},
-- disable_devicons = true,
-- maximum_results = 1000,
}
),
pickers.new({
prompt = "Large search",
finder = finders.new_oneshot_job({ "fdfind" }, {
cwd = cwd,
entry_maker = make_entry.gen_from_file { cwd = cwd },
-- disable_devicons = true,
-- maximum_results = 1000,
}),
sorter = sorters.get_fuzzy_file(),
previewer = previewers.cat.new{cwd = cwd},
}:find()
previewer = previewers.cat.new { cwd = cwd },
}):find()
-- vim.wait(3000, function()
-- vim.cmd [[redraw!]]

View File

@@ -1,24 +1,24 @@
require('plenary.reload').reload_module('telescope')
require("plenary.reload").reload_module "telescope"
local finders = require('telescope.finders')
local pickers = require('telescope.pickers')
local sorters = require('telescope.sorters')
local previewers = require('telescope.previewers')
local make_entry = require('telescope.make_entry')
local finders = require "telescope.finders"
local pickers = require "telescope.pickers"
local sorters = require "telescope.sorters"
local previewers = require "telescope.previewers"
local make_entry = require "telescope.make_entry"
local my_list = {
'lua/telescope/WIP.lua',
'lua/telescope/actions.lua',
'lua/telescope/builtin.lua',
"lua/telescope/WIP.lua",
"lua/telescope/actions.lua",
"lua/telescope/builtin.lua",
}
local opts = {}
pickers.new(opts, {
prompt = 'Telescope Builtin',
finder = finders.new_table {
prompt = "Telescope Builtin",
finder = finders.new_table {
results = my_list,
},
sorter = sorters.get_generic_fuzzy_sorter(),
sorter = sorters.get_generic_fuzzy_sorter(),
previewer = previewers.cat.new(opts),
}):find()

View File

@@ -1,18 +1,18 @@
-- TODO: Add a ladder test.
-- 1, 2, 4, 8, 16, 32 attempts
RELOAD('plenary')
RELOAD "plenary"
-- RELOAD('telescope')
local profiler = require('plenary.profile.lua_profiler')
local Job = require('plenary.job')
local profiler = require "plenary.profile.lua_profiler"
local Job = require "plenary.job"
BIG_LIST = nil
BIG_LIST = BIG_LIST or Job:new { command = 'fdfind', cwd = '~/build/' }:sync()
BIG_LIST = BIG_LIST or Job:new({ command = "fdfind", cwd = "~/build/" }):sync()
print(#BIG_LIST)
local do_profile = true
local sorter_to_test = require('telescope.sorters').get_fuzzy_file()
local sorter_to_test = require("telescope.sorters").get_fuzzy_file()
local strings_to_test = { "", "ev", "eval.c", "neovim/eval.c" }
@@ -25,7 +25,7 @@ local first_results = setmetatable({}, {
local obj = {}
rawset(t, k, obj)
return obj
end
end,
})
local second_results = {}
@@ -66,6 +66,5 @@ print(vim.inspect(first_results))
if do_profile then
profiler.stop()
profiler.report('/home/tj/tmp/profiler_score.txt')
profiler.report "/home/tj/tmp/profiler_score.txt"
end

View File

@@ -1,19 +1,24 @@
-- local actions = require('telescope.actions')
-- local utils = require('telescope.utils')
require('telescope')
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')
require "telescope"
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 log = require('telescope.log')
local log = require "telescope.log"
local real_opts = setmetatable({}, { __mode = 'v' })
local opts = setmetatable({}, {
__index = function(t, k) log.debug("accessing:", k); return real_opts[k] end,
__newindex = function(t, k, v) log.debug("setting:", k, v); real_opts[k] = v end
local real_opts = setmetatable({}, { __mode = "v" })
local opts = setmetatable({}, {
__index = function(t, k)
log.debug("accessing:", k)
return real_opts[k]
end,
__newindex = function(t, k, v)
log.debug("setting:", k, v)
real_opts[k] = v
end,
})
opts.entry_maker = opts.entry_maker or make_entry.gen_from_file()
@@ -31,17 +36,14 @@ end
-- assert(not opts.entry_maker)
local picker_config = {
prompt = 'Git File',
finder = finders.new_oneshot_job(
{ "git", "ls-files", "-o", "--exclude-standard", "-c" }
, opts
),
prompt = "Git File",
finder = finders.new_oneshot_job({ "git", "ls-files", "-o", "--exclude-standard", "-c" }, opts),
-- previewer = previewers.cat.new(opts),
-- sorter = sorters.get_fuzzy_file(opts),
-- sorter = sorters.get_fuzzy_file(),
}
log.debug("Done with config")
log.debug "Done with config"
local x = pickers.new(picker_config)
x:find()

View File

@@ -1,12 +1,10 @@
RELOAD('telescope')
RELOAD "telescope"
local resolve = require('telescope.config.resolve')
local resolve = require "telescope.config.resolve"
local eq = function(a, b)
if a ~= b then
error(string.format(
"Expected a == b, got: %s and %s", vim.inspect(a), vim.inspect(b)
))
error(string.format("Expected a == b, got: %s and %s", vim.inspect(a), vim.inspect(b)))
end
end
@@ -25,30 +23,29 @@ eq(height_config, opt.preview)
eq(height_config, opt.prompt)
eq(height_config, opt.results)
local table_val = {'a'}
local table_val = { "a" }
opt = resolve.win_option(nil, table_val)
eq(table_val, opt.preview)
eq(table_val, opt.prompt)
eq(table_val, opt.results)
local prompt_override = {'a', prompt = 'b'}
local prompt_override = { "a", prompt = "b" }
opt = resolve.win_option(prompt_override)
eq('a', opt.preview)
eq('a', opt.results)
eq('b', opt.prompt)
eq("a", opt.preview)
eq("a", opt.results)
eq("b", opt.prompt)
local all_specified = {preview = 'a', prompt = 'b', results = 'c'}
local all_specified = { preview = "a", prompt = "b", results = "c" }
opt = resolve.win_option(all_specified)
eq('a', opt.preview)
eq('b', opt.prompt)
eq('c', opt.results)
local some_specified = {prompt = 'b', results = 'c'}
opt = resolve.win_option(some_specified, 'a')
eq('a', opt.preview)
eq('b', opt.prompt)
eq('c', opt.results)
eq("a", opt.preview)
eq("b", opt.prompt)
eq("c", opt.results)
local some_specified = { prompt = "b", results = "c" }
opt = resolve.win_option(some_specified, "a")
eq("a", opt.preview)
eq("b", opt.prompt)
eq("c", opt.results)
eq(10, resolve.resolve_height(0.1)(nil, 24, 100))
eq(2, resolve.resolve_width(0.1)(nil, 24, 100))
@@ -62,4 +59,4 @@ eq(24, resolve.resolve_width(50)(nil, 24, 100))
-- eq('b', opt.prompt)
-- eq('c', opt.results)
print("DONE!")
print "DONE!"

View File

@@ -1,12 +1,12 @@
RELOAD('telescope')
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 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 {}
@@ -18,11 +18,8 @@ local slow_proc = function(opts)
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
),
prompt = "Slow Proc",
finder = finders.new_oneshot_job({ "./scratch/slow_proc.sh" }, opts),
previewer = previewers.cat.new(opts),
sorter = sorters.get_fuzzy_file(),
@@ -31,21 +28,24 @@ local slow_proc = function(opts)
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
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,
}))
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)
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(text, true, false, true), "n", true)
end
if false then
@@ -64,7 +64,6 @@ local slow_proc = function(opts)
end))
end
p:find()
end