summaryrefslogtreecommitdiff
path: root/lua/telescope/pickers/entry_display.lua
diff options
context:
space:
mode:
authorjulianf <julianf@digitalbakery.net>2022-06-30 16:03:55 +0200
committerSimon Hauser <Simon-Hauser@outlook.de>2022-07-01 16:59:10 +0200
commita0a038170dbb5e4b69a50f648a8cf5cae6a910a3 (patch)
tree5515f2100ead2e48fba803950132ce5749acd4a0 /lua/telescope/pickers/entry_display.lua
parent8f56fede21f6bb2a2e5e600d78d75509dff821ca (diff)
docs: `make_entry` and `entry_display`
Diffstat (limited to 'lua/telescope/pickers/entry_display.lua')
-rw-r--r--lua/telescope/pickers/entry_display.lua60
1 files changed, 60 insertions, 0 deletions
diff --git a/lua/telescope/pickers/entry_display.lua b/lua/telescope/pickers/entry_display.lua
index b1a1473..6e520f4 100644
--- a/lua/telescope/pickers/entry_display.lua
+++ b/lua/telescope/pickers/entry_display.lua
@@ -1,3 +1,63 @@
+---@tag telescope.pickers.entry_display
+
+---@brief [[
+--- Entry Display is used to format each entry shown in the result panel.
+---
+--- Entry Display create() will give us a function based on the configuration
+--- of column widths we pass into it. We then can use this function n times to
+--- return a string based on structured input.
+---
+--- Note that if you call `create()` inside `make_display` it will be called for
+--- every single entry. So it is suggested to do this outside of `make_display`
+--- for the best performance.
+---
+--- The create function will use the column widths passed to it in
+--- configaration.items. Each item in that table is the number of characters in
+--- the column. It's also possible for the final column to not have a fixed
+--- width, this will be shown in the configuartion as 'remaining = true'.
+---
+--- An example of this configuration is shown for the buffers picker
+--- <code>
+--- local displayer = entry_display.create {
+--- separator = " ",
+--- items = {
+--- { width = opts.bufnr_width },
+--- { width = 4 },
+--- { width = icon_width },
+--- { remaining = true },
+--- },
+--- }
+--- </code>
+---
+--- This shows 4 columns, the first is defined in the opts as the width we'll
+--- use when display_string the number of the buffer. The second has a fixed
+--- width of 4 and the 3rd column's widht will be decided by the width of the
+--- icons we use. The fourth column will use the remaining space. Finally we
+--- have also defined the seperator between each column will be the space " ".
+---
+--- An example of how the display reference will be used is shown, again for
+--- the buffers picker:
+--- <code>
+--- return displayer {
+--- { entry.bufnr, "TelescopeResultsNumber" },
+--- { entry.indicator, "TelescopeResultsComment" },
+--- { icon, hl_group },
+--- display_bufname .. ":" .. entry.lnum,
+--- }
+--- </code>
+---
+--- There are two types of values each column can have. Either a simple String
+--- or a table containing the String as well as the hl_group.
+---
+--- The displayer can return values, string and an optional highlights.
+--- String is all the text to be displayed for this entry as a single string. If
+--- parts of the string are to be highlighted they will be described in the
+--- highlights table.
+---
+--- For better understanding of how create() and displayer are used it's best to look
+--- at the code in make_entry.lua.
+---@brief ]]
+
local strings = require "plenary.strings"
local state = require "telescope.state"
local resolve = require "telescope.config.resolve"