Questions about MiniPick customization and configuration #1718
-
Contributing guidelines
Module(s)mini.pick QuestionI have three questions if possible: 1.Is it possible to add a selection cursor in 2.Is there a way to separate the colors of One possible idea for how this could be configured:window.prompt_prefix = {">", "hl_groups"}
window.prompt_cursor = {"|", "hl_groups"} I'm not sure if there's a correct way to achieve this or if 3.How do you configure the search in |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 7 replies
-
Yes, it should be possible by writing custom Predicting next question here: no, it will not be built-in or behind another new configuration option.
No, there is not. The whole prompt is highlighted with I'll think about adding separate
Through setting
|
Beta Was this translation helpful? Give feedback.
-
@krovuxdev, there are now And a heads up: |
Beta Was this translation helpful? Give feedback.
-
It is now fully possible via using The most robust approach here is to actually not write global -- Automatically wrap picker's `source.show` to do some extra work of showing
-- gutter sign. This is needed over defining global `config.source.show` to
-- account for picker-specific ways of showing items (like showing icons or
-- not, etc.).
local show_gutter_ns_id = vim.api.nvim_create_namespace('mini-pick-show-gutter')
local wrap_show_with_gutter = function()
local picker_opts = MiniPick.get_picker_opts()
local show_fun = picker_opts.source.show
picker_opts.source.show = function(buf_id, items_to_show, query)
show_fun(buf_id, items_to_show, query)
-- Show fresh gutter as extmark with inline virtual text:
-- " " for non-current item, "> " for current
vim.api.nvim_buf_clear_namespace(buf_id, show_gutter_ns_id, 0, -1)
local matches = MiniPick.get_picker_matches()
local shown_inds, cur_ind = matches.shown_inds, matches.current_ind
if shown_inds == nil or cur_ind == nil then return end
local prefix_extmark_opts = { virt_text = { { ' ', 'MiniPickNormal' } }, virt_text_pos = 'inline' }
for i = 1, vim.api.nvim_buf_line_count(buf_id) do
prefix_extmark_opts.virt_text[1][1] = (shown_inds[i] == cur_ind and cur_ind ~= nil) and '> ' or ' '
vim.api.nvim_buf_set_extmark(buf_id, show_gutter_ns_id, i - 1, 0, prefix_extmark_opts)
end
end
MiniPick.set_picker_opts(picker_opts)
end
vim.api.nvim_create_autocmd('User', { pattern = 'MiniPickStart', callback = wrap_show_with_gutter }) |
Beta Was this translation helpful? Give feedback.
Yes, it should be possible by writing custom
source.show
. To get which item is current, usecurrent_ind
inget_picker_matches()
output.Predicting next question here: no, it will not be built-in or behind another new configuration option.
No, there is not. The whole prompt is highlighted with
MiniPickPrompt
highlight group.I'll think about adding separate
MiniPickPromptPrefix
andMiniPickPromptCursor
, but there is a fundamental issue. Prompt is implemented as title/footer whic…