summaryrefslogtreecommitdiff
path: root/lua/telescope/actions/set.lua
diff options
context:
space:
mode:
authorelianiva <dicha.arkana03@gmail.com>2021-03-05 20:13:48 +0700
committerGitHub <noreply@github.com>2021-03-05 20:13:48 +0700
commit6e941e0ecec1ab6a1b4ce40c693ef1272c505abb (patch)
tree7d8c273d98909a238cdc7f09b7453bfd8577c443 /lua/telescope/actions/set.lua
parent8369acea3e6b0258f125ea251111e3217655b11c (diff)
feat: define scroll speed + smart_send to qflist (#610)
* smart send to qflist * Previewer scrolling for half window height * Start doing cleanup in readme * feat: add ability to define the scrolling speed * move scrolling action to action.set * docs: added more docs for actions * [docgen] Update doc/telescope.txt skip-checks: true Co-authored-by: Simon Hauser <Simon-Hauser@outlook.de> Co-authored-by: Github Actions <actions@github>
Diffstat (limited to 'lua/telescope/actions/set.lua')
-rw-r--r--lua/telescope/actions/set.lua13
1 files changed, 13 insertions, 0 deletions
diff --git a/lua/telescope/actions/set.lua b/lua/telescope/actions/set.lua
index f55f3e7..ea46e83 100644
--- a/lua/telescope/actions/set.lua
+++ b/lua/telescope/actions/set.lua
@@ -2,6 +2,7 @@ local a = vim.api
local log = require('telescope.log')
local path = require('telescope.path')
+local state = require('telescope.state')
local action_state = require('telescope.actions.state')
@@ -124,6 +125,18 @@ set.edit = function(prompt_bufnr, command)
end
end
+--- Scrolls the previewer up or down
+---@param prompt_bufnr number: The prompt bufnr
+---@param direction number: The direction of the scrolling
+-- Valid directions include: "1", "-1"
+set.scroll_previewer = function (prompt_bufnr, direction)
+ local status = state.get_status(prompt_bufnr)
+ local default_speed = vim.api.nvim_win_get_height(status.preview_win) / 2
+ local speed = status.picker.layout_config.scroll_speed or default_speed
+
+ action_state.get_current_picker(prompt_bufnr).previewer:scroll_fn(math.floor(speed * direction))
+end
+
-- ==================================================
-- Transforms modules and sets the corect metatables.
-- ==================================================