Repository navigation
Expand file tree
/
Copy pathsnacks.lua
More file actions
156 lines (156 loc) · 4.13 KB
/
Copy pathsnacks.lua
File metadata and controls
156 lines (156 loc) · 4.13 KB
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
-- Snacks.nvim configuration
-- Provides dashboard, indent guides, and file picker
return {
"folke/snacks.nvim",
opts = {
dashboard = {
preset = {
header = [[Hey Joe 👋!]],
},
},
image = {
math = { enabled = false },
},
indent = {
scope = { enabled = false },
animate = { enabled = false },
},
scroll = {
enabled = false,
},
picker = {
matcher = { frecency = true },
layout = {
layout = {
width = 0.9,
height = 0.9,
},
},
formatters = {
file = {
filename_first = true,
truncate = 100,
},
},
sources = {
explorer = {
ignored = true,
layout = {
layout = {
width = 40,
},
},
win = {
list = {
keys = {
["x"] = "explorer_cut",
},
},
},
actions = {
explorer_cut = function(picker)
local files = {}
for _, item in ipairs(picker:selected({ fallback = true })) do
if item.file then
table.insert(files, item.file)
end
end
if #files == 0 then
return
end
local value = table.concat(files, "\n")
vim.fn.setreg("+", value, "l")
vim.fn.setreg(vim.v.register, value, "l")
vim.g.snacks_explorer_cut = files
picker.list:set_selected()
end,
explorer_paste = function(picker)
local files = vim.tbl_filter(function(f)
return f ~= ""
end, vim.split(vim.fn.getreg(vim.v.register) or "", "\n", { plain = true }))
local is_cut = vim.deep_equal(files, vim.g.snacks_explorer_cut)
files = vim.tbl_filter(function(f)
return vim.fn.filereadable(f) == 1 or vim.fn.isdirectory(f) == 1
end, files)
if #files == 0 then
return Snacks.notify.warn("Nothing to paste")
end
local dir = picker:dir()
local function done()
require("snacks.explorer.tree"):refresh(dir)
require("snacks.explorer.tree"):open(dir)
require("snacks.explorer.actions").update(picker, { target = dir })
end
if not is_cut then
Snacks.picker.util.copy(files, dir)
return done()
end
vim.g.snacks_explorer_cut = nil
for _, src in ipairs(files) do
local dest = dir .. "/" .. vim.fs.basename(src)
if vim.uv.fs_stat(dest) then
Snacks.notify.error(("Move skipped, `%s` already exists"):format(dest))
else
Snacks.rename.rename_file({ from = src, to = dest })
require("snacks.explorer.tree"):refresh(vim.fs.dirname(src))
end
end
done()
end,
},
},
projects = {
patterns = {
".obsidian",
"go.mod",
".git",
"Makefile",
"package.json",
".bzr",
".hg",
".svn",
"_darcs",
},
dev = { "~/Code", "~/Obsidian" },
max_depth = 3,
},
git_diff = {
layout = {
layout = {
width = 0.95,
height = 0.95,
},
},
},
gh_issue = {
layout = {
layout = {
width = 0.95,
height = 0.95,
},
},
},
gh_pr = {
layout = {
layout = {
width = 0.95,
height = 0.95,
},
},
},
},
ignored = false,
hidden = true,
},
statuscolumn = {},
},
keys = {
{
"<C-p>",
function()
Snacks.picker.files()
end,
desc = "Find Files (Root Dir)",
},
},
}