Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated docs to clarify which telescope.defaults options can be overriden by pickers #3251

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions lua/telescope/builtin/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,17 @@
---
--- :lua require('telescope.builtin').$NAME_OF_PICKER()
---
--- To use any of Telescope's default options or any picker-specific options, call your desired picker by passing a lua
--- table to the picker with all of the options you want to use. Here's an example with the live_grep picker:
--- To configure your desired picker, call it by passing a lua table with all
--- of the options you want to use. Pickers have their own specific set of
--- options, but also accept a subset of the defaults options. The default
--- options which are valid to configure a picker are marked as
--- "Picker-Overridable" in telescope.setup.defaults
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'll probably be easier to mark options that aren't "picker-overriable".
In theory, all but a small handful can at least in technically be overriden by the each individual picker.

I would reword this bit slightly and let's leave out the marking of individual options an "Picker-Overridable" for now.

--- Here's an example with the live_grep picker:
---
--- <code>
--- :lua require('telescope.builtin').live_grep({
--- prompt_title = 'find string in open buffers...',
--- grep_open_files = true
--- prompt_title = 'find string in open buffers...', -- Default option overriden for this specific picker
--- grep_open_files = true -- Option specific to live_grep picker
--- })
--- -- or with dropdown theme
--- :lua require('telescope.builtin').find_files(require('telescope.themes').get_dropdown{
Expand Down
33 changes: 30 additions & 3 deletions lua/telescope/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ local layout_config_description = string.format(
the screen width for all strategies except 'center', which has width
of 50%% of the screen width.

Picker-Overridable
Default: %s
]],
vim.inspect(layout_config_defaults, { newline = "\n ", indent = " " })
Expand All @@ -149,7 +150,9 @@ append(

Available options are:
- "descending" (default)
- "ascending"]]
- "ascending"

Picker-Overridable ]]
)

append(
Expand All @@ -163,7 +166,9 @@ append(
- "follow"
- "row"
- "closest"
- "none"]]
- "none"

Picker-Overridable]]
)

append(
Expand All @@ -175,7 +180,9 @@ append(

Available options are:
- "cycle" (default)
- "limit"]]
- "limit"

Picker-Overridable]]
)

append(
Expand All @@ -185,6 +192,7 @@ append(
Determines the default layout of Telescope pickers.
See |telescope.layout| for details of the available strategies.

Picker-Overridable
Default: 'horizontal']]
)

Expand All @@ -195,6 +203,7 @@ append(
Configure the layout of Telescope pickers.
See |telescope.pickers.layout| for details.

Picker-Overridable
Default: 'nil']]
)

Expand All @@ -213,6 +222,7 @@ append(
2. table
A table with possible keys `layout_strategy`, `layout_config` and `previewer`

Picker-Overridable
Default: { "horizontal", "vertical" }
]]
)
Expand All @@ -227,6 +237,7 @@ append(
more information. Type can be a number or a function returning a
number

Picker-Overridable
Default: function() return vim.o.winblend end]]
)

Expand All @@ -236,6 +247,7 @@ append(
[[
Word wrap the search results

Picker-Overridable
Default: false]]
)

Expand All @@ -245,6 +257,7 @@ append(
[[
The character(s) that will be shown in front of Telescope's prompt.

Picker-Overridable
Default: '> ']]
)

Expand All @@ -254,6 +267,7 @@ append(
[[
The character(s) that will be shown in front of the current selection.

Picker-Overridable
Default: '> ']]
)

Expand All @@ -263,6 +277,7 @@ append(
[[
Prefix in front of each result entry. Current selection not included.

Picker-Overridable
Default: ' ']]
)

Expand All @@ -275,6 +290,7 @@ append(
|telescope.defaults.entry_prefix| as appropriate.
To have no icon, set to the empty string.

Picker-Overridable
Default: '+']]
)

Expand All @@ -285,6 +301,7 @@ append(
Determines in which mode telescope starts. Valid Keys:
`insert` and `normal`.

Picker-Overridable
Default: "insert"]]
)

Expand All @@ -294,6 +311,7 @@ append(
[[
Boolean defining if borders are added to Telescope windows.

Picker-Overridable
Default: true]]
)

Expand Down Expand Up @@ -402,6 +420,7 @@ append(
Set the borderchars of telescope floating windows. It has to be a
table of 8 string values.

Picker-Overridable
Default: { "─", "│", "─", "│", "╭", "╮", "╯", "╰" }]]
)

Expand Down Expand Up @@ -448,6 +467,7 @@ append(
A function that determines what the virtual text looks like.
Signature: function(picker) -> str

Picker-Overridable
Default: function that shows current count / all]]
)

Expand Down Expand Up @@ -479,6 +499,7 @@ append(
Defines the default title of the results window. A false value
can be used to hide the title altogether.

Picker-Overridable
Default: "Results"]]
)

Expand All @@ -490,6 +511,7 @@ append(
can be used to hide the title altogether. Most of the times builtins
define a prompt_title which will be preferred over this default.

Picker-Overridable
Default: "Prompt"]]
)

Expand Down Expand Up @@ -593,6 +615,7 @@ append(
the prompt is empty (i.e., no text has been
typed at the time of closing the prompt).
Default: false
Picker-Overridable
]]
)

Expand Down Expand Up @@ -808,6 +831,8 @@ append(
Vice versa always returning true would place the current_entry
before the existing_entry.

Picker-Overridable

Signature: function(current_entry, existing_entry, prompt) -> boolean

Default: function that breaks the tie based on the length of the
Expand Down Expand Up @@ -835,6 +860,7 @@ append(
and have fd and or ripgrep installed because both tools will not show
`gitignore`d files on default.

Picker-Overridable
Default: nil]]
)

Expand All @@ -848,6 +874,7 @@ append(
The window ID will be used to decide what window the chosen file will
be opened in and the cursor placed in upon leaving the picker.

Picker-Overridable
Default: `function() return 0 end`
]]
)
Expand Down
16 changes: 12 additions & 4 deletions lua/telescope/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -106,18 +106,26 @@ local telescope = {}
--- pickers = {
--- -- Default configuration for builtin pickers goes here:
--- -- picker_name = {
--- -- picker_config_key = value,
--- -- default_config_key = value_one
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
--- -- default_config_key = value_one
--- -- default_config_key = value_one, -- optionally override any default options

--- -- picker_config_key = value_two,
--- -- ...
--- -- }
--- -- Now the picker_config_key will be applied every time you call this
--- -- builtin picker
--- -- Options set here will be applied everytime you call this builtin
--- -- picker. Each entry accepts a subset of the "defaults" configuration
--- -- options, as well as the picker's own specific configuration options.
--- -- Defaults options that are also valid for pickers are marked as
--- -- "Picker-Overridable" in telescope.setup.defaults. Learn about one
--- -- picker's specific set of options at telescope.builtin.$PICKER_NAME
Comment on lines +113 to +118
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
--- -- Options set here will be applied everytime you call this builtin
--- -- picker. Each entry accepts a subset of the "defaults" configuration
--- -- options, as well as the picker's own specific configuration options.
--- -- Defaults options that are also valid for pickers are marked as
--- -- "Picker-Overridable" in telescope.setup.defaults. Learn about one
--- -- picker's specific set of options at telescope.builtin.$PICKER_NAME
--- -- Options set here will be applied everytime you call this builtin
--- -- picker. The pickers will also inherit the "default" options unless
--- -- they are overwritten.
--- -- See `:h telescope.builtin` for options unique to each picker.

--- },
--- extensions = {
--- -- Your extension configuration goes here:
--- -- extension_name = {
--- -- extension_config_key = value,
--- -- }
--- -- please take a look at the readme of the extension you want to configure
--- -- Extensions should generally accept the same subset of defaults config
--- -- options as builtin pickers, although that may differ depending on the
--- -- extension. Make sure to read the extension's README or builtin
--- -- documentation to know its specific configuration options.
--- }
--- }
--- </code>
Expand Down