feat: Consistent and sensible layout_config (#922)
* feat: Consistent and sensible layout_config * [docgen] Update doc/telescope.txt skip-checks: true * [WIP]: Thu 17 Jun 2021 03:36:44 PM EDT * [WIP]: Thu 17 Jun 2021 03:38:11 PM EDT * layout_default -> layout_defaults * remove options from bug repot * Conni2461 suggestions: part 1 * [docgen] Update doc/telescope.txt skip-checks: true * Conni2461 suggestions: part 2 * [docgen] Update doc/telescope.txt skip-checks: true * Linting * Improve deprecation checks - Move `layout_defaults` handling to `deprecated.lua` - Check for "layout keys" outside of `layout_config` on `setup` * fixup: Just add a few more words Co-authored-by: Luke Kershaw <35707277+l-kershaw@users.noreply.github.com> Co-authored-by: Github Actions <actions@github>
This commit is contained in:
@@ -14,6 +14,7 @@ local actions = require('telescope.actions')
|
||||
local action_set = require('telescope.actions.set')
|
||||
local config = require('telescope.config')
|
||||
local debounce = require('telescope.debounce')
|
||||
local deprecated = require('telescope.deprecated')
|
||||
local log = require('telescope.log')
|
||||
local mappings = require('telescope.mappings')
|
||||
local state = require('telescope.state')
|
||||
@@ -56,6 +57,8 @@ function Picker:new(opts)
|
||||
actions._clear()
|
||||
action_set._clear()
|
||||
|
||||
deprecated.picker_window_options(opts)
|
||||
|
||||
local layout_strategy = get_default(opts.layout_strategy, config.values.layout_strategy)
|
||||
|
||||
local obj = setmetatable({
|
||||
@@ -96,33 +99,13 @@ function Picker:new(opts)
|
||||
selection_strategy = get_default(opts.selection_strategy, config.values.selection_strategy),
|
||||
|
||||
layout_strategy = layout_strategy,
|
||||
layout_config = get_default(
|
||||
opts.layout_config,
|
||||
(config.values.layout_defaults or {})[layout_strategy]
|
||||
) or {},
|
||||
layout_config = vim.tbl_deep_extend("keep", opts.layout_config or {}, config.values.layout_config or {}),
|
||||
|
||||
window = {
|
||||
-- TODO: This won't account for different layouts...
|
||||
-- TODO: If it's between 0 and 1, it's a percetnage.
|
||||
-- TODO: If its's a single number, it's always that many columsn
|
||||
-- TODO: If it's a list, of length 2, then it's a range of min to max?
|
||||
height = get_default(opts.height, 0.8),
|
||||
width = get_default(opts.width, config.values.width),
|
||||
|
||||
get_preview_width = get_default(opts.preview_width, config.values.get_preview_width),
|
||||
|
||||
results_width = get_default(opts.results_width, config.values.results_width),
|
||||
results_height = get_default(opts.results_height, config.values.results_height),
|
||||
|
||||
winblend = get_default(opts.winblend, config.values.winblend),
|
||||
prompt_position = get_default(opts.prompt_position, config.values.prompt_position),
|
||||
|
||||
-- Border config
|
||||
border = get_default(opts.border, config.values.border),
|
||||
borderchars = get_default(opts.borderchars, config.values.borderchars),
|
||||
},
|
||||
|
||||
preview_cutoff = get_default(opts.preview_cutoff, config.values.preview_cutoff),
|
||||
}, self)
|
||||
|
||||
obj.get_window_options = opts.get_window_options or p_window.get_window_options
|
||||
|
||||
Reference in New Issue
Block a user