-
Notifications
You must be signed in to change notification settings - Fork 193
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
Beta-testing 'mini.pick' #513
Comments
Hi, thanks for the cool plugin! I'm trying to make a picker similar to How can I pass the word under the cursor as a query when creating the picker? I tried using Here is an example of what I tried to do: local pick = require('mini.pick')
pick.registry.grep_live_current_buf = function()
local lines = vim.api.nvim_buf_get_lines(0, 1, -1, false)
local items = {}
local path = vim.fn.expand('%p')
for lnum, line in ipairs(lines) do
items[lnum] = { text = line, lnum = lnum + 1, path = path }
end
pick.start({
source = {
items = items,
name = 'Grep current buffer',
},
})
pick.set_picker_query(vim.split(vim.fn.expand('<cword>'), ''))
end As I understood from the plugin code, the initial query is always set empty in the private function |
If it wasn't for only current buffer restriction, I'd suggest using
Your code is good, it only misses one important design: although So in your code by the time Here is my attempt: MiniPick.registry.buffer_lines = function(local_opts)
-- Parse options
local_opts = vim.tbl_deep_extend('force', { buf_id = nil, prompt = '' }, local_opts or {})
local buf_id, prompt = local_opts.buf_id, local_opts.prompt
local_opts.buf_id, local_opts.prompt = nil, nil
-- Construct items
if buf_id == nil or buf_id == 0 then buf_id = vim.api.nvim_get_current_buf() end
local lines = vim.api.nvim_buf_get_lines(buf_id, 0, -1, false)
local items = {}
for i, l in ipairs(lines) do
items[i] = { text = string.format('%d:%s', i, l), bufnr = buf_id, lnum = i }
end
-- Start picker while scheduling setting the query
vim.schedule(function() MiniPick.set_picker_query(vim.split(prompt, '')) end)
MiniPick.start({ source = { items = items, name = 'Buffer lines' } })
end |
Thanks for the quick reply! UPD: works with your example, thanks again! |
I saw this issue after I filed mine, huge apologies. TLDR is Pick grep searches .git folder, which isn't really useful. Excellent plugin! |
No worries. I'll think about it. |
Gosh this one is amazing! The speed increase compared to Telescope is staggering. You should be really proud of what you've created here. I'm struggling to figure out how to browse files in another directory. With Telescope, I had to Is there a mechanism to tell |
❤️
It is possible, as every source can have "current working directory". So with It is made a part of the source for it to be more persistent and not depend on current working directory. Allowing it also as the local option for built-in picker is a code duplication I would like to avoid. Thus the modification of To be honest, I did not realize that picking something from different directory is a common thing. I'd make it more prominent in the documentation. Maybe this is a workflow thing. I use |
That first incantation is a little awkward, but works perfectly for me. Thanks!
I’d encourage that! I (hope) I’m not the only person who’s wanted to do that, because if so then I’ve missed the point somewhere along the way.
My use case there is primarily mini.starter. I have a couple projects that I often want to work on or examine a particular file in, and spawning nvim and browsing one of those dirs is a very common workflow for me. |
Duplicating from #516: suggested approach is to set up custom |
Hello @echasnovski,
|
Yes, this is working as intended because matching algorithm is the same by default for any picker. If you add
What do you mean by "paste to input"?
|
Sorry, my typo. I can't paste in |
What do you mean by "paste"? There is a paste action with default mapping of |
Copy something from other then paste to |
System clipboard can be accessed via one of So on my machine I can select text from this page (select, click with right mouse button, select "Copy"). Then go into Neovim, execute |
I'm triggering mini.pick by the following mechanism vim.keymap.set("n", "<leader>f", ":Pick files<CR>", { noremap = true, silent = true })
vim.keymap.set("n", "<leader>/", ":Pick grep<CR>", { noremap = true, silent = true })
vim.keymap.set("n", "<leader>b", ":Pick buffers<CR>", { noremap = true, silent = true }) I'm finding neither
|
Would you mind go into a bit more detail? Like:
|
I'm on Mac OS & Most of the other bindings appear to be working, When pressing |
I think I have an idea what might be going on. What does Edit: Hmm... But you seem to use 'mini.base16', which should set visible |
If I disable As soon as I do Running
whether I've got |
Yep, it is a 'mini.base16' issue. I forgot that floating window in it has the same background as cursor line. I'll fix it soon. Edit: @Jackevansevo, I've pushed a 'mini.base16' update with tweaked highlight groups for 'mini.pick'. Should be all visible on latest |
Is there any way require("mini.pick").setup({
mappings = {
mark = nil,
mark_and_move = {
char = "<C-X>",
func = function(picker)
H.actions.mark(picker)
H.actions.move_down(picker)
end
}
}
}) but isn't because of the way actions are defined, unless I'm missing something. |
Yeah, I thought about that. The main reason for not exporting this is that there are already too much exported and I would like to limit it. The solution for this case I assumed would be to create custom mapping emulating "mark" and "move_down" key presses. Something like this: require('mini.pick').setup({
mappings = {
mark_and_down = {
char = '<C-d>',
func = function() vim.api.nvim_input(vim.api.nvim_replace_termcodes('<C-x><C-n>', true, true, true)) end,
},
},
}) |
@echasnovski Yes, that worked. Not the most convenient. Personally, I prefer the way telescope and, I believe, fzf-lua do mappings, where you map keycodes to actions, but this does get there. |
@echasnovski As a note, this works as well and can account for anything that would change the setup: |
Well, to be even more precise, it should account for possible picker-local mappings. Like this: local mark_and_move_down = function()
local mappings = MiniPick.get_picker_opts().mappings
local keys = mappings.mark .. mappings.move_down
vim.api.nvim_input(vim.api.nvim_replace_termcodes(keys, true, true, true))
end
require('mini.pick').setup({
mappings = {
mark_and_down = { char = '<C-d>', func = mark_and_move_down },
},
}) |
confirmed this is working perfectly now, cheers for the help 👍 |
is there a way to enable preview automatically? |
@JulesNP, today I realized that I can make |
Awesome. Just updated and can report that it is working fine 👍 |
Thanks! Everything's working great with the latest changes. I've fully switched over from Telescope now in my config. |
I want to express my gratitude first for creating all these fantastic modules. I've been utilizing While Additionally, I'm curious if there's a way to customize the appearance of each pick. For instance, I'd like pick buffers or files to be much smaller and positioned in the bottom right, unlike grep_live, which I prefer to have in a larger window. On a related note, I'm wondering if there's a method to implement grep_live specifically for help files (not the one for only help tags). I attempted to do so, but the outcome was less than satisfactory. Apologies for the less-than-ideal implementation. My attempt for Pick help_grep
config = function(_, opts)
local MiniPick = require("mini.pick")
MiniPick.setup({})
MiniPick.registry.help_files = function(local_opts)
-- Parse options
local_opts = vim.tbl_deep_extend("force", { prompt = "" }, local_opts or {})
local prompt = local_opts.prompt
local_opts.prompt = nil
-- Get the paths of the help files
local paths = vim.api.nvim_get_option("runtimepath")
paths = vim.split(paths, ",")
local dirs = {}
for _, path in ipairs(paths) do
local doc_path = path .. "/doc"
if vim.fn.isdirectory(doc_path) == 1 then
table.insert(dirs, doc_path)
end
end
-- Start the picker based on CLI output
MiniPick.builtin.cli({
command = {
"rg",
prompt,
"--color",
"never",
"--no-messages",
"--line-buffered",
"-g",
"!*.log",
"-n",
"-H",
unpack(dirs),
},
prompt_title = "Help Grep",
}, local_opts)
end
end, thank you for your time and assistance! |
Thanks for kind words! Much appreciated 🙏
Thanks for the suggestion! I'll think about it, but initial reaction is that this is unlikely to happen. There is a certain novel undo integration in 'mini.bracketed' (see its
Yes, it is possible. All pickers in Here is a quick example of how to create a new picker MiniPick.registry.help_right = function()
local win_config =
{ relative = 'editor', anchor = 'SE', row = vim.o.lines, col = vim.o.columns, height = 20, width = 40 }
return MiniPick.builtin.help({}, { window = { config = win_config } })
end Having this executed (after
I would advise not to try and implement specifically a What you have is a variant of That said, I'd suggest to go another route completely. Take a look at
You can wrap those two steps in a single function if you'd like. |
Hi ! Thanks a lot for I've been wondering if there was something I could do to switch my For example, I'd like the default behavior of To keep the configuration method consistent with the chosen solution, in the case of I saw that there is already support for cwd for the grep tool subprocess, And for simplicity, it would be nice to be able to concatenate arbitrary This way, we could either do: MiniPick.builtin.grep_live({tool = "rg"}, {source = {env = {"RIPGREP_CONFIG_PATH" = "/path/to/specific/configuration"}}}) or MiniPick.builtin.grep_live({tool = "rg"}, {source = {args = {"--hidden"}}}) This wouldn't need any tool specific handling from |
I think the best solution here would be to write a wrapper function which temporarily sets the environment variables. Something like this: MiniPick.registry.grep_live_specific = function()
local cache_rg_config = vim.uv.os_getenv('RIPGREP_CONFIG_PATH')
vim.uv.os_setenv('RIPGREP_CONFIG_PATH', '/path/to/specific/configuration')
MiniPick.builtin.grep_live({ tool = 'rg' })
vim.uv.os_setenv('RIPGREP_CONFIG_PATH', cache_rg_config)
end You can then call it with
For other CLI related tasks there is a |
Thanks, this works like a charm ! |
I really like your work. My setup contains only mini.nvim and a few others for LSP. But I'm having trouble getting mini.pick to work. |
Hi, thanks! Without additional information I can not really help. For example:
|
working: Arch, neovim 0.9.4
I'm using those via keybinding, but nothing shows beside the empty window :(
Nothing shown EDIT: |
My guess would be that both 0.10.0 versions are too old and don't have the floating window footer feature. Either using latest Nightly appimage or indeed rebuilding latest nightly from source should solve the issue in this case. |
As usual, you are absolutly right :) Rebuild both nvim versions solved my problem. Thanks. |
Is there a way to resume just one individual picker? I would like to set a keymap to always open live_grep with the last searched word, basically something similar to fzf live_grep_resume. |
Unfortunately, no. It would require storing too much data, so there is only one You can kind of implement this by overriding local latest_grep_live_query = {}
MiniPick.registry.grep_live = function(local_opts)
local cache_query_and_choose = function(...)
latest_grep_live_query = MiniPick.get_picker_query()
return MiniPick.default_choose(...)
end
return MiniPick.builtin.grep_live(local_opts, { source = { choose = cache_query_and_choose } })
end
MiniPick.registry.grep_live_resume = function(local_opts)
vim.schedule(function() MiniPick.set_picker_query(latest_grep_live_query) end)
return MiniPick.registry.grep_live(local_opts)
end With this you can use |
With the release of 0.11.0, 'mini.pick' is now out of beta-testing. Huge thanks to everyone for constructive feedback and participation! |
@echasnovski Thank you for your work and dedication! I immediately switched to it and I don't see any point to switch back. |
Thank you for the very nice plugin. Is there a way to have ignorecase when doing grep_live? |
|
Thanks a lot Evgeni! Did not know about ripgrep's config file. Works beautifully! |
Hi, thanks for the great plugin! |
|
Thanks for the quick reply! It's just that I don't want to have a dependency on |
As My suggestion would be to either use |
Note @echasnovski I'm not sure if this is appropriate to add here on this older gh issue but thought it was better than opening a new gh issue or something (since it is not an issue but a question / request). Please let me know for the future what protocol you would prefer I follow for items like these! For mini pickers, is there a way to have preview split out to side of the main picker items? similar to how telescope does it so you can cycle through the items in the picker and have the preview shown on the right side for example. Also similar to how you have mini.files working in concept where you can navigate the list of items and the preview is shown to the right. Thanks! |
There is a separate Q&A category for discussion which is dedicated for this type of interaction.
I am afraid, no. The whole idea is to have it be single window only while separate preview needs extra window. The 'mini.pick' approach is to have preview enabled with |
No worries! Thanks for the response. I kind of figured as such given your approach (which I appreciate) with trying to keep code as simple and concise as possible while maximizing features/value. Cycling through while in preview gets me most the way there. |
Please leave your feedback about new mini.pick module here. Feel free to either add new comment or positively upvote existing one.
Some things I am interested to find out (obviously, besides bugs):
Thanks!
The text was updated successfully, but these errors were encountered: