diff --git a/lua/telescope/config.lua b/lua/telescope/config.lua index 716141664c..88e32d93fc 100644 --- a/lua/telescope/config.lua +++ b/lua/telescope/config.lua @@ -930,6 +930,17 @@ append( Default: require("telescope.previewers").buffer_previewer_maker]] ) +append( + "buffer_scroll_fn", + function(...) + return require("telescope.previewers").buffer_scroll_fn(...) + end, + [[ + Function pointer to the default scroll function in buffer previewers. + + Default: require("telescope.previewers").buffer_scroll_fn]] +) + -- @param user_defaults table: a table where keys are the names of options, -- and values are the ones the user wants -- @param tele_defaults table: (optional) a table containing all of the defaults diff --git a/lua/telescope/previewers/buffer_previewer.lua b/lua/telescope/previewers/buffer_previewer.lua index da11227e9e..5c38dba225 100644 --- a/lua/telescope/previewers/buffer_previewer.lua +++ b/lua/telescope/previewers/buffer_previewer.lua @@ -307,7 +307,7 @@ local search_teardown = function(self) end end -local scroll_fn = function(self, direction) +previewers.scroll_fn = function(self, direction) if not self.state then return end @@ -475,7 +475,7 @@ previewers.new_buffer_previewer = function(opts) end if not opts.scroll_fn then - opts.scroll_fn = scroll_fn + opts.scroll_fn = conf.buffer_scroll_fn end if not opts.scroll_horizontal_fn then diff --git a/lua/telescope/previewers/init.lua b/lua/telescope/previewers/init.lua index b066040752..5f8f98feaa 100644 --- a/lua/telescope/previewers/init.lua +++ b/lua/telescope/previewers/init.lua @@ -243,6 +243,9 @@ previewers.new_buffer_previewer = buffer_previewer.new_buffer_previewer ---@param opts table: keys: `use_ft_detect`, `bufname` and `callback` previewers.buffer_previewer_maker = buffer_previewer.file_maker +--- A function to scroll the buffer of buffer previewers +previewers.buffer_scroll_fn = buffer_previewer.scroll_fn + --- A previewer that is used to display a file. It uses the `buffer_previewer` --- interface and won't jump to the line. To integrate this one into your --- own picker make sure that the field `path` or `filename` is set for