Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Telescope Preview #79

Open
niksingh710 opened this issue Feb 9, 2023 · 3 comments
Open

Telescope Preview #79

niksingh710 opened this issue Feb 9, 2023 · 3 comments
Labels
enhancement New feature or request

Comments

@niksingh710
Copy link

How to enable this to work in preview window of other programs like telescope

@karb94 karb94 added the enhancement New feature or request label Feb 4, 2024
@jheroy
Copy link

jheroy commented Apr 16, 2024

Any progress?

@karb94
Copy link
Owner

karb94 commented Apr 16, 2024

Planned but not much progress yet

@karb94
Copy link
Owner

karb94 commented Nov 12, 2024

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()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants