preview items#2533
Conversation
require('fzf-lua').register_ui_select()
vim.ui.select(vim.fn.range(10), {
preview_item = function(entry_str)
return {
content = { '## ' .. entry_str },
line = 1,
col = 1 + #'## ',
end_col = 1 + #'## ' + #entry_str,
filetype = 'markdown',
}
end,
}, print)EDIT: require("fzf-lua").register_ui_select()
vim.ui.select(vim.fn.range(10), {
preview_item = function(entry_str)
return {
content = { { { "## " }, { entry_str, "IncSearch" } } },
filetype = "markdown",
}
end,
}, print) |
|
Amazing @phanen, is this ready for merging or you want to play with it some more until I merge? |
|
Maybe we can wait upstream to be merged (maybe they can change function signatures, to give more spec about what preview_items should return) |
7d5cc26 to
7e7d470
Compare
|
7d5cc26 - great idea |
fix(previewer): valid again after coroutine resume
d9ab67d to
dacfffc
Compare
|
Tested with phanen/fzf-lua-extra@6c8b373, a picker for https://github.com/alex-popov-tech/store.nvim |
|
Do you want this merged or still wanna wait for neovim/neovim#37360? |
entry.content can be `(string|fzf-lua.line)[]` ---@alias fzf-lua.line (string|[string,string])[] The second part is hlgroup chore: simplify highlight previewer
fix(previewer): update_render_markdown if it's enabled
|
Ok, I think no problem to merge. |
|
Ty @phanen, sorry for the delay as traveling, hope to get to it from the airport :) |
|
Tysm @phanen |
|
hi, great to see this proposal already landing in fzf-lua, I am the one who first raised the issue, since I want to simplify all the picker integrations in obsidian.nvim I am basically wanting to do this: ---@param values string[]|obsidian.PickerEntry[]
---@param opts obsidian.PickerPickOpts|? Options.
M.pick = function(values, opts)
opts = opts or {}
local callback = opts.callback or obsidian.api.open_note
local format_item = opts.format_item or function(entry)
return tostring(entry.user_data)
end
require("fzf-lua.providers.ui_select").ui_select(values, {
format_item = format_item,
preview_item = function(entry)
local buf = vim.api.nvim_create_buf(false, true)
vim.api.nvim_buf_set_lines(buf, 0, -1, false, { "hi" })
return {
buf = buf,
}
end,
prompt = format_prompt(opts.prompt_title),
}, function(entry)
if not entry then
log.info "Aborted"
return
end
callback(entry)
end)
endwhich is in compliance to the updated proposal in the upsteam issue, maybe this was merged earlier then the updated proposal, but in short the updated proposal requires only one field which is the just a heads up, maybe we should wait till it gets merged to update accordingly. |
|
Yeah, currently |
|
fixed in #2722 |
opts.preview_items: neovim/neovim#37360