feat: Added some docs & validation
This commit is contained in:
24
README.md
24
README.md
@@ -372,6 +372,30 @@ Themes should work with every `telescope.builtin` function.
|
|||||||
|
|
||||||
If you wish to make theme, check out `lua/telescope/themes.lua`. If you need more features, make an issue :).
|
If you wish to make theme, check out `lua/telescope/themes.lua`. If you need more features, make an issue :).
|
||||||
|
|
||||||
|
## Configuration
|
||||||
|
|
||||||
|
### Display
|
||||||
|
|
||||||
|
`Resolvable`:
|
||||||
|
1. 0 <= number < 1:
|
||||||
|
- This means total height as a percentage
|
||||||
|
2. 1 <= number:
|
||||||
|
- This means total height as a fixed number
|
||||||
|
3. function(picker, columns, lines):
|
||||||
|
- returns one of the above options
|
||||||
|
- `return max.min(110, max_rows * .5)`
|
||||||
|
|
||||||
|
```lua
|
||||||
|
layout_strategies.horizontal = function(self, max_columns, max_lines)
|
||||||
|
local layout_config = validate_layout_config(self.layout_config or {}, {
|
||||||
|
width_padding = "How many cells to pad the width",
|
||||||
|
height_padding = "How many cells to pad the height",
|
||||||
|
preview_width = "(Resolvable): Determine preview width",
|
||||||
|
})
|
||||||
|
...
|
||||||
|
end
|
||||||
|
```
|
||||||
|
|
||||||
## Goals
|
## Goals
|
||||||
|
|
||||||
### Pipeline Different Objects
|
### Pipeline Different Objects
|
||||||
|
|||||||
@@ -32,19 +32,13 @@ Result of `resolve` should be a table with:
|
|||||||
!!NOT IMPLEMENTED YET!!
|
!!NOT IMPLEMENTED YET!!
|
||||||
|
|
||||||
height =
|
height =
|
||||||
1. pass between 0 & 1
|
1. 0 <= number < 1
|
||||||
This means total height as a percentage
|
This means total height as a percentage
|
||||||
|
|
||||||
2. pass a number > 1
|
2. 1 <= number
|
||||||
This means total height as a fixed number
|
This means total height as a fixed number
|
||||||
|
|
||||||
3. {
|
3. function(picker, columns, lines)
|
||||||
previewer = x,
|
|
||||||
results = x,
|
|
||||||
prompt = x,
|
|
||||||
}, this means I do my best guess I can for these, given your options
|
|
||||||
|
|
||||||
4. function(max_rows)
|
|
||||||
-> returns one of the above options
|
-> returns one of the above options
|
||||||
return max.min(110, max_rows * .5)
|
return max.min(110, max_rows * .5)
|
||||||
|
|
||||||
@@ -54,6 +48,12 @@ height =
|
|||||||
return 0.6
|
return 0.6
|
||||||
end
|
end
|
||||||
|
|
||||||
|
3. {
|
||||||
|
previewer = x,
|
||||||
|
results = x,
|
||||||
|
prompt = x,
|
||||||
|
}, this means I do my best guess I can for these, given your options
|
||||||
|
|
||||||
width =
|
width =
|
||||||
exactly the same, but switch to width
|
exactly the same, but switch to width
|
||||||
|
|
||||||
|
|||||||
@@ -33,6 +33,21 @@ local is_borderless = function(opts)
|
|||||||
return opts.window.border == false
|
return opts.window.border == false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local function validate_layout_config(options, values)
|
||||||
|
for k, _ in pairs(options) do
|
||||||
|
if not values[k] then
|
||||||
|
error(string.format(
|
||||||
|
"Unsupported layout_config key: %s\n%s",
|
||||||
|
k,
|
||||||
|
vim.inspect(values)
|
||||||
|
))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return options
|
||||||
|
end
|
||||||
|
|
||||||
local layout_strategies = {}
|
local layout_strategies = {}
|
||||||
|
|
||||||
--[[
|
--[[
|
||||||
@@ -46,7 +61,11 @@ local layout_strategies = {}
|
|||||||
+-----------------+---------------------+
|
+-----------------+---------------------+
|
||||||
--]]
|
--]]
|
||||||
layout_strategies.horizontal = function(self, max_columns, max_lines)
|
layout_strategies.horizontal = function(self, max_columns, max_lines)
|
||||||
local layout_config = self.layout_config or {}
|
local layout_config = validate_layout_config(self.layout_config or {}, {
|
||||||
|
width_padding = "How many cells to pad the width",
|
||||||
|
height_padding = "How many cells to pad the height",
|
||||||
|
preview_width = "(Resolvable): Determine preview width",
|
||||||
|
})
|
||||||
|
|
||||||
local initial_options = self:_get_initial_window_options()
|
local initial_options = self:_get_initial_window_options()
|
||||||
local preview = initial_options.preview
|
local preview = initial_options.preview
|
||||||
|
|||||||
Reference in New Issue
Block a user