Skip to content

Commit

Permalink
fix(previewer): buffer_previewer_maker now receives all necessary opt…
Browse files Browse the repository at this point in the history
…s everywhere (#2833)
  • Loading branch information
atusy authored Jan 23, 2024
1 parent 36dce62 commit 301505d
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions lua/telescope/previewers/buffer_previewer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ end, {})

previewers.qflist = previewers.vimgrep

previewers.ctags = defaulter(function(_)
previewers.ctags = defaulter(function(opts)
local determine_jump = function(entry)
if entry.scode then
return function(self)
Expand Down Expand Up @@ -646,17 +646,19 @@ previewers.ctags = defaulter(function(_)
conf.buffer_previewer_maker(entry.filename, self.state.bufnr, {
bufname = self.state.bufname,
winid = self.state.winid,
preview = opts.preview,
callback = function(bufnr)
pcall(vim.api.nvim_buf_call, bufnr, function()
determine_jump(entry)(self, bufnr)
end)
end,
file_encoding = opts.file_encoding,
})
end,
}
end, {})

previewers.builtin = defaulter(function(_)
previewers.builtin = defaulter(function(opts)
return previewers.new_buffer_previewer {
title = "Grep Preview",
teardown = search_teardown,
Expand All @@ -677,15 +679,17 @@ previewers.builtin = defaulter(function(_)
conf.buffer_previewer_maker(entry.filename, self.state.bufnr, {
bufname = self.state.bufname,
winid = self.state.winid,
preview = opts.preview,
callback = function(bufnr)
search_cb_jump(self, bufnr, text)
end,
file_encoding = opts.file_encoding,
})
end,
}
end, {})

previewers.help = defaulter(function(_)
previewers.help = defaulter(function(opts)
return previewers.new_buffer_previewer {
title = "Help Preview",
teardown = search_teardown,
Expand All @@ -702,10 +706,12 @@ previewers.help = defaulter(function(_)
conf.buffer_previewer_maker(entry.filename, self.state.bufnr, {
bufname = self.state.bufname,
winid = self.state.winid,
preview = opts.preview,
callback = function(bufnr)
putils.regex_highlighter(bufnr, "help")
search_cb_jump(self, bufnr, query)
end,
file_encoding = opts.file_encoding,
})
end,
}
Expand Down Expand Up @@ -981,6 +987,8 @@ previewers.git_file_diff = defaulter(function(opts)
conf.buffer_previewer_maker(p, self.state.bufnr, {
bufname = self.state.bufname,
winid = self.state.winid,
preview = opts.preview,
file_encoding = opts.file_encoding,
})
else
local cmd = git_command({ "--no-pager", "diff", "HEAD", "--", entry.value }, opts)
Expand Down

0 comments on commit 301505d

Please sign in to comment.