Skip to content

Commit 5a53ec5

Browse files
tjdevriesl-kershawGithub Actions
authored
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 <[email protected]> Co-authored-by: Github Actions <actions@github>
1 parent e5bd496 commit 5a53ec5

File tree

16 files changed

+1274
-503
lines changed

16 files changed

+1274
-503
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

+1-33
Original file line numberDiff line numberDiff line change
@@ -88,37 +88,5 @@ Plug 'nvim-telescope/telescope.nvim'
8888
call plug#end()
8989
9090
autocmd VimEnter * PlugClean! | PlugUpdate --sync | close
91-
lua << EOF
92-
93-
require('telescope').setup{
94-
defaults = {
95-
vimgrep_arguments = {
96-
'rg',
97-
'--color=never',
98-
'--no-heading',
99-
'--with-filename',
100-
'--line-number',
101-
'--column',
102-
'--smart-case'
103-
},
104-
prompt_position = "bottom",
105-
prompt_prefix = ">",
106-
selection_strategy = "reset",
107-
sorting_strategy = "descending",
108-
layout_strategy = "horizontal",
109-
layout_defaults = {},
110-
file_ignore_patterns = {},
111-
shorten_path = true,
112-
winblend = 0,
113-
width = 0.75,
114-
preview_cutoff = 120,
115-
results_height = 1,
116-
results_width = 0.8,
117-
border = {},
118-
borderchars = { '─', '│', '─', '│', '╭', '╮', '╯', '╰'},
119-
color_devicons = true,
120-
use_less = true,
121-
}
122-
}
123-
EOF
91+
lua require('telescope').setup()
12492
```

README.md

+37-35
Original file line numberDiff line numberDiff line change
@@ -138,15 +138,14 @@ require('telescope').setup{
138138
'--column',
139139
'--smart-case'
140140
},
141-
prompt_position = "bottom",
142141
prompt_prefix = "> ",
143142
selection_caret = "> ",
144143
entry_prefix = " ",
145144
initial_mode = "insert",
146145
selection_strategy = "reset",
147146
sorting_strategy = "descending",
148147
layout_strategy = "horizontal",
149-
layout_defaults = {
148+
layout_config = {
150149
horizontal = {
151150
mirror = false,
152151
},
@@ -159,10 +158,6 @@ require('telescope').setup{
159158
generic_sorter = require'telescope.sorters'.get_generic_fuzzy_sorter,
160159
shorten_path = true,
161160
winblend = 0,
162-
width = 0.75,
163-
preview_cutoff = 120,
164-
results_height = 1,
165-
results_width = 0.8,
166161
border = {},
167162
borderchars = { '', '', '', '', '', '', '', '' },
168163
color_devicons = true,
@@ -196,24 +191,19 @@ EOF
196191

197192
| Keys | Description | Options |
198193
|------------------------|-------------------------------------------------------|----------------------------|
199-
| `prompt_position` | Where the prompt should be located. | top/bottom |
200194
| `prompt_prefix` | What should the prompt prefix be. | string |
201195
| `selection_caret` | What should the selection caret be. | string |
202196
| `entry_prefix` | What should be shown in front of every entry. (current selection excluded) | string|
203197
| `initial_mode` | The initial mode when a prompt is opened. | insert/normal |
204-
| `sorting_strategy` | Where first selection should be located. | descending/ascending |
205198
| `layout_strategy` | How the telescope is drawn. | [supported layouts](https://github.com/nvim-telescope/telescope.nvim/wiki/Layouts) |
206-
| `winblend` | How transparent is the telescope window should be. | NUM |
207-
| `layout_defaults` | Extra settings for fine-tuning how your layout looks | [supported settings](https://github.com/nvim-telescope/telescope.nvim/wiki/Layouts#layout-defaults) |
208-
| `width` | TODO | NUM |
209-
| `preview_cutoff` | TODO | NUM |
210-
| `results_height` | TODO | NUM |
211-
| `results_width` | TODO | NUM |
199+
| `layout_config` | Extra settings for fine-tuning how your layout looks | [supported settings](https://github.com/nvim-telescope/telescope.nvim/wiki/Layouts#layout-defaults) |
200+
| `sorting_strategy` | Where first selection should be located. | descending/ascending |
201+
| `scroll_strategy` | How to behave when the when there are no more item next/prev | cycle, nil |
202+
| `winblend` | How transparent is the telescope window should be. | number |
212203
| `borderchars` | The border chars, it gives border telescope window | dict |
213204
| `color_devicons` | Whether to color devicons or not | boolean |
214205
| `use_less` | Whether to use less with bat or less/cat if bat not installed | boolean |
215206
| `set_env` | Set environment variables for previewer | dict |
216-
| `scroll_strategy` | How to behave when the when there are no more item next/prev | cycle, nil |
217207
| `file_previewer` | What telescope previewer to use for files. | [Previewers](#previewers) |
218208
| `grep_previewer` | What telescope previewer to use for grep and similar | [Previewers](#previewers) |
219209
| `qflist_previewer` | What telescope previewer to use for qflist | [Previewers](#previewers) |
@@ -446,7 +436,7 @@ Built-in functions. Ready to be bound to any key you like. :smile:
446436
| `builtin.current_buffer_fuzzy_find` | Live fuzzy search inside of the currently open buffer |
447437
| `builtin.current_buffer_tags` | Lists all of the tags for the currently open buffer, with a preview |
448438

449-
### LSP Pickers
439+
### Neovim LSP Pickers
450440

451441
| Functions | Description |
452442
|---------------------------------------------|-------------------------------------------------------------------------------------------------------------------|
@@ -644,7 +634,6 @@ Picker:new{
644634
selection_strategy = "reset", -- follow, reset, row
645635
border = {},
646636
borderchars = {"", "", "", "", "", "", "", ""},
647-
preview_cutoff = 120,
648637
default_selection_index = 1, -- Change the index of the initial selection row
649638
}
650639
```
@@ -677,24 +666,37 @@ end
677666
### Layout (display)
678667
<!-- TODO need some work -->
679668

680-
`Resolvable`:
681-
1. 0 <= number < 1:
682-
- This means total height as a percentage
683-
2. 1 <= number:
684-
- This means total height as a fixed number
685-
3. function(picker, columns, lines):
686-
- returns one of the above options
687-
- `return max.min(110, max_rows * .5)`
688-
689-
```lua
690-
layout_strategies.horizontal = function(self, max_columns, max_lines)
691-
local layout_config = validate_layout_config(self.layout_config or {}, {
692-
width_padding = "How many cells to pad the width",
693-
height_padding = "How many cells to pad the height",
694-
preview_width = "(Resolvable): Determine preview width",
695-
})
696-
...
697-
end
669+
Layout can be configured by choosing a specific `layout_strategy` and
670+
specifying a particular `layout_config` for that strategy.
671+
For more details on available strategies and configuration options,
672+
see `:help telescope.layout`.
673+
674+
Some options for configuring sizes in layouts are "resolvable".
675+
This means that they can take different forms, and will be interpreted differently according to which form they take.
676+
For example, if we wanted to set the `width` of a picker using the `vertical`
677+
layout strategy to 50% of the screen width, we would specify that width
678+
as `0.5`, but if we wanted to specify the `width` to be exactly 80
679+
characters wide, we would specify it as `80`.
680+
For more details on resolving sizes, see `:help telescope.resolve`.
681+
682+
As an example, if we wanted to specify the layout strategy and width,
683+
but only for this instance, we could do something like:
684+
```
685+
:lua require('telescope.builtin').find_files({layout_strategy='vertical',layout_config={width=0.5}})
686+
```
687+
or if we wanted to change the width for every time we use the `vertical`
688+
layout strategy, we could add the following to our `setup()` call:
689+
```
690+
require('telescope').setup({
691+
defaults = {
692+
layout_config = {
693+
vertical = { width = 0.5 }
694+
-- other layout configuration here
695+
},
696+
-- other defaults configuration here
697+
},
698+
-- other configuration values here
699+
})
698700
```
699701

700702
## Vim Commands

0 commit comments

Comments
 (0)