feat: Better border configuration.

Started adding `resolve` which will allow you to do some really nice
stuff easily with options to get the window options from a variety of
inputs.

You can see how we do it in pickers.lua for borders & borderchars
currently.
This commit is contained in:
TJ DeVries
2020-09-12 14:56:58 -04:00
parent 58ab225dca
commit f449c0499c
4 changed files with 127 additions and 8 deletions

View File

@@ -0,0 +1,58 @@
RELOAD('telescope')
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)
))
end
end
local opt = nil
local height_config = 0.8
opt = resolve.win_option(height_config)
eq(height_config, opt.preview)
eq(height_config, opt.prompt)
eq(height_config, opt.results)
opt = resolve.win_option(nil, height_config)
eq(height_config, opt.preview)
eq(height_config, opt.prompt)
eq(height_config, opt.results)
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'}
opt = resolve.win_option(prompt_override)
eq('a', opt.preview)
eq('a', opt.results)
eq('b', opt.prompt)
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)
-- local true_table = {true}
-- opt = resolve.win_option(some_specified, 'a')
-- eq('a', opt.preview)
-- eq('b', opt.prompt)
-- eq('c', opt.results)
print("DONE!")