How can a preset be extended/overriden #1319
-
I am finding it very difficult to override preset default config. When i try to copy the layout directly and place directly, the picker doesnt work. What am i doing wrong? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
In the I have created three telescope-like layouts opts = {
picker = {
-- The default layout preset.
layout = function()
return vim.o.columns >= 120 and 'my_telescope'
or vim.o.lines >= 25 and 'my_telescope_vertical'
or 'my_telescope_vertical_no_preview'
end,
previewers = {
...
},
sources = {
...
select = { layout = { preset = 'my_select' } },
},
layouts = {
my_telescope = {
-- A borderless layout with a vertical split with a preview on the right.
-- - Based on the default `telescope` layout.
-- - Replaces `rounded` with `solid` borders.
reverse = true,
layout = {
box = 'horizontal',
backdrop = false,
width = 0.8,
height = 0.9,
border = 'none',
{
box = 'vertical',
{ win = 'list', title = ' Results ', title_pos = 'center', border = 'solid' },
{ win = 'input', height = 1, border = 'solid', title = '{title} {live} {flags}', title_pos = 'center' },
},
{
win = 'preview',
title = '{preview:Preview}',
width = 0.45,
border = 'solid',
title_pos = 'center',
},
},
},
my_telescope_vertical = {
...
},
my_telescope_vertical_no_preview = {
...
},
my_select = {
...
},
},
... |
Beta Was this translation helpful? Give feedback.
In the
opts.picker.layouts
table, you can overwrite or define your own layout presets. The specified name can then be used.I have created three telescope-like layouts
my_telescope
,my_telescope_vertical
, andmy_telescope_vertical_no_preview
and use them depending on the window size inopts.picker.layout
as default. Inopts.picker.sources
you can. set the layout per picker or in the picker call directlysnacks.picker.files({layout = { preset = 'my_telescope' }})
.