(mini.pick) - how to pick files from specific directory? #642
-
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Every source can have "current working directory". So with If you plan to do that often interactively, you can modify |
Beta Was this translation helpful? Give feedback.
-
@echasnovski, having one with the code you've provided. If I hit enter on the selection(i.e "choose" the selection) then it selects the file, but if I "Ctrl+v"(i.e "choose_in_vsplit") then it changes my directory. My `mini.pick` configlocal function pick_cmd(cmd)
return "<cmd>Pick " .. cmd .. "<cr>"
end
---@type LazySpec
return {
'echasnovski/mini.pick',
dependencies = {
{ 'echasnovski/mini.icons', config = function() require('mini.icons').setup() end },
{
'echasnovski/mini.extra',
config = function()
require('mini.extra').setup()
end,
},
},
cmd = { 'Pick' },
keys = {
{ '<C-p>', pick_cmd("files"), desc = '[F]ile' },
{
'<leader>fn',
pick_cmd(string.format("files cwd='%s'", vim.fn.stdpath("config"))),
desc = '[N]eovim config',
},
}
opts = {
mappings = {
choose_in_split = '<C-x>',
mark = '<C-l>',
move_down = '<C-j>',
move_up = '<C-k>',
}
options = { use_cache = true },
},
config = function(_, opts)
local picker = require("mini.pick")
picker.setup(opts)
-- Make `:Pick files` accept `cwd`
MiniPick.registry.files = function(local_opts)
local opts = { source = { cwd = local_opts.cwd } }
local_opts.cwd = nil
return MiniPick.builtin.files(local_opts, opts)
end
vim.ui.select = picker.ui_select
end
}
output.mov |
Beta Was this translation helpful? Give feedback.
Every source can have "current working directory". So with
builtin.files()
you can doMiniPick.builtin.files(nil, { source = { cwd = '../foo/bar' } })
.If you plan to do that often interactively, you can modify
files
in registry and use:Pick files cwd='../foo/bar'
.