summaryrefslogtreecommitdiff
path: root/lua/telescope/actions/generate.lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua/telescope/actions/generate.lua')
-rw-r--r--lua/telescope/actions/generate.lua56
1 files changed, 56 insertions, 0 deletions
diff --git a/lua/telescope/actions/generate.lua b/lua/telescope/actions/generate.lua
new file mode 100644
index 0000000..fafce8c
--- /dev/null
+++ b/lua/telescope/actions/generate.lua
@@ -0,0 +1,56 @@
+---@tag telescope.actions.generate
+
+---@brief [[
+--- Module for convenience to override defaults of corresponding |telescope.actions| at |telescope.setup()|.
+---
+--- <pre>
+--- General usage:
+--- require("telescope").setup {
+--- defaults = {
+--- mappings = {
+--- n = {
+--- ["?"] = action_generate.toggle_registered_actions {
+--- name_width = 20, -- typically leads to smaller floats
+--- max_height = 0.5, -- increase potential maximum height
+--- seperator = " > ", -- change sep between mode, keybind, and name
+--- close_with_action = false, -- do not close float on action
+--- },
+--- },
+--- },
+--- },
+--- }
+--- </pre>
+---@brief ]]
+
+local actions = require "telescope.actions"
+local action_generate = {}
+
+--- Display the keymaps of registered actions similar to which-key.nvim.<br>
+--- - Floating window:
+--- - Appears on the opposite side of the prompt.
+--- - Resolves to minimum required number of lines to show hints with `opts` or truncates entries at `max_height`.
+--- - Closes automatically on action call and can be disabled with by setting `close_with_action` to false.
+---@param opts table: options to pass to toggling registered actions
+---@field max_height number: % of max. height or no. of rows for hints (default: 0.4), see |resolver.resolve_height()|
+---@field only_show_current_mode boolean: only show keymaps for the current mode (default: true)
+---@field mode_width number: fixed width of mode to be shown (default: 1)
+---@field keybind_width number: fixed width of keybind to be shown (default: 7)
+---@field name_width number: fixed width of action name to be shown (default: 30)
+---@field column_padding string: string to split; can be used for vertical seperator (default: " ")
+---@field mode_hl string: hl group of mode (default: TelescopeResultsConstant)
+---@field keybind_hl string: hl group of keybind (default: TelescopeResultsVariable)
+---@field name_hl string: hl group of action name (default: TelescopeResultsFunction)
+---@field column_indent number: number of left-most spaces before keybinds are shown (default: 4)
+---@field line_padding number: row padding in top and bottom of float (default: 1)
+---@field separator string: seperator string between mode, key bindings, and action (default: " -> ")
+---@field close_with_action boolean: registered action will close keymap float (default: true)
+---@field normal_hl string: winhl of "Normal" for keymap hints floating window (default: "TelescopePrompt")
+---@field border_hl string: winhl of "Normal" for keymap borders (default: "TelescopePromptBorder")
+---@field winblend number: pseudo-transparency of keymap hints floating window
+action_generate.which_key = function(opts)
+ return function(prompt_bufnr)
+ actions.which_key(prompt_bufnr, opts)
+ end
+end
+
+return action_generate