Repository navigation
Expand file tree
/
Copy pathsnacks.lua
More file actions
154 lines (154 loc) · 3.94 KB
/
Copy pathsnacks.lua
File metadata and controls
154 lines (154 loc) · 3.94 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
-- 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 sel = picker:selected({ fallback = true })
local files = {}
for _, item in ipairs(sel) do
if item.file then
table.insert(files, item.file)
end
end
if #files == 0 then
return
end
vim.fn.setreg("+", table.concat(files, "\n"))
vim.g.snacks_explorer_cut = files
picker.list:set_selected()
end,
explorer_paste = function(picker)
local cut = vim.g.snacks_explorer_cut or {}
local files
local is_cut = #cut > 0
if is_cut then
files = vim.deepcopy(cut)
else
files = vim.split(vim.fn.getreg("+") or "", "\n", { plain = true })
end
files = vim.tbl_filter(function(f)
return f ~= "" and (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()
if is_cut then
for _, src in ipairs(files) do
local dest = dir .. "/" .. vim.fs.basename(src)
local ok, err = vim.uv.fs_rename(src, dest)
if not ok then
Snacks.notify.error(("Move failed: %s -> %s\n%s"):format(src, dest, err))
end
end
vim.g.snacks_explorer_cut = nil
else
Snacks.picker.util.copy(files, dir)
end
require("snacks.explorer.tree"):refresh(dir)
require("snacks.explorer.tree"):open(dir)
require("snacks.explorer.actions").update(picker, { target = dir })
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)",
},
},
}