1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
return {
"mini.pick",
lazy = true,
cmd = "Pick",
after = function()
local win_config = function()
local height = math.floor(0.618 * vim.o.lines)
local width = math.floor(0.618 * vim.o.columns)
return {
anchor = 'NW', height = height, width = width,
row = math.floor(0.5 * (vim.o.lines - height)),
col = math.floor(0.5 * (vim.o.columns - width)),
}
end
require("mini.pick").setup {
window = {
config = win_config,
},
}
vim.cmd.packadd("mini.extra")
require("mini.extra").setup()
vim.ui.select = MiniPick.ui_select
-- Switch to a dir in the zoxide database
MiniPick.registry.zoxide = function()
local zoxide_output = vim.fn.system('zoxide query -l')
local zoxide_dirs = vim.split(zoxide_output, '\n', { trimempty = true })
MiniPick.start({
source = {
items = zoxide_dirs,
name = "zoxide",
choose = function(dir)
vim.fn.chdir(dir)
end
}
})
end
-- Switch to a subdir of the current dir
MiniPick.registry.cd = function(local_opts)
local scope = local_opts.scope or 'current'
local fd_output = vim.fn.system('fd -t d')
local fd_dirs = vim.split(fd_output, '\n', { trimempty = true })
MiniPick.start({
source = {
items = fd_dirs,
name = (scope == 'tab') and "tcd" or "cd",
choose = function (dir)
if (scope == 'tab') then
vim.cmd.tcd(dir)
else
vim.cmd.cd(dir)
end
end
}
})
end
end
}
|