Skip to content

Commit

Permalink
feat(buffer_previewer): add Neoscroll support
Browse files Browse the repository at this point in the history
  • Loading branch information
karb94 committed Nov 10, 2024
1 parent 85922dd commit 63871f4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ wiki.
- [nvim-treesitter/nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter) (finder/preview)
- [neovim LSP](https://neovim.io/doc/user/lsp.html) (picker)
- [devicons](https://github.com/nvim-tree/nvim-web-devicons) (icons)
- [karb94/neoscroll.nvim](https://github.com/karb94/neoscroll.nvim) (smooth scrolling preview)

### Installation

Expand Down
7 changes: 6 additions & 1 deletion lua/telescope/previewers/buffer_previewer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ local putils = require "telescope.previewers.utils"
local Previewer = require "telescope.previewers.previewer"
local conf = require("telescope.config").values
local global_state = require "telescope.state"
local has_neoscroll, neoscroll = pcall(require, "neoscroll")

local pscan = require "plenary.scandir"

Expand Down Expand Up @@ -475,7 +476,11 @@ previewers.new_buffer_previewer = function(opts)
end

if not opts.scroll_fn then
opts.scroll_fn = scroll_fn
if has_neoscroll then
opts.scroll_fn = neoscroll.telescope_scroll_fn
else
opts.scroll_fn = scroll_fn
end
end

if not opts.scroll_horizontal_fn then
Expand Down

0 comments on commit 63871f4

Please sign in to comment.