Replies: 3 comments 11 replies
-
There is no documentation for |
Beta Was this translation helpful? Give feedback.
-
To set a specific line and column for an item's file previewer, define picker = {
sources = {
files = {
transform = function(item)
item.pos = { 2, 1 }
end, |
Beta Was this translation helpful? Give feedback.
-
I am building a custom Picker where I want to load the preview as the item is iterated. How to implement the preview function to do that. I can't load the preview with the results as the list is too big, and also, for each preview, I have to run a command via vim.fn.jobstart, which makes it very slow. here is the code snippet of picker Snacks.picker.pick {
items = results,
title = title,
format = function(item, _)
if not item or not item.display then return { { "" } } end
-- Return TWO text segments, each with a different highlight group
return {
{ " ", "Icon" },
{ item.display, "PickWin" }, -- Highlight the topic name
}
end,
layout = {
preset = "default", -- or your preferred layout
cycle = true,
layout = {
title = title,
},
},
preview = function(ctx)
if not ctx.item then return true end
local item = ctx.item
inspect(item)
local prev_cmd = opts.preview_cmd
local type = type(prev_cmd)
if type == "string" then
prev_cmd = { "ros2", prev_cmd, item.value }
elseif type == "function" then
prev_cmd = prev_cmd(item) or ""
elseif type == "table" then
prev_cmd = table.insert(prev_cmd, 1, "ros")
end
if prev_cmd == nil then return end
JobRunner.run(prev_cmd, {
on_complete = function(preview)
if preview then
-- Here I want to put the preview content in the picker.
end
end,
})
end,
}
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Where is the documentation for ctx.preview for example
ctx.preview:highlight
andctx.preview:set_lines
? I want to preview part of the current file starting at some line.Beta Was this translation helpful? Give feedback.
All reactions