Telescope Preview
Opened this issue · 3 comments
niksingh710 commented
How to enable this to work in preview window of other programs like telescope
jheroy commented
Any progress?
karb94 commented
Planned but not much progress yet
karb94 commented
Unfortunately, for this to work out of the box with the default telescope buffer previewers I need Telescope to allow Neoscroll to replace their default scroll_fn()
function. I opened a PR for this purpose.
The scroll_fn()
function can be passed to custom previewers but not to the default ones so without this PR I can only create custom previewers with smooth scrolling but I doubt many people would use even if they are otherwise identical to the default ones. Here is a working example:
local builtin = require("telescope.builtin")
local previewers = require("telescope.previewers")
local from_entry = require("telescope.from_entry")
local conf = require("telescope.config").values
local neoscroll = require('neoscroll')
local my_previewer = function(opts)
return previewers.new_buffer_previewer({
scroll_fn = neoscroll.telescope_scroll_fn,
define_preview = function(self, entry)
local p = from_entry.path(entry, true, false)
if p == nil or p == "" then
return
end
conf.buffer_previewer_maker(p, self.state.bufnr, {
bufname = self.state.bufname,
winid = self.state.winid,
preview = opts.preview,
file_encoding = opts.file_encoding,
})
end,
})
end
local function my_picker(opts)
local opts = opts or {}
opts.previewer = my_previewer(opts)
builtin.buffers(opts)
end
my_picker()