-
-
Notifications
You must be signed in to change notification settings - Fork 317
Expand file tree
/
Copy pathinit.lua
More file actions
101 lines (95 loc) · 3.46 KB
/
Copy pathinit.lua
File metadata and controls
101 lines (95 loc) · 3.46 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
-- This function is taken from LazyVim: https://github.com/LazyVim/LazyVim/blob/cb223553ff73eb2f37ffb5dc0bb75b76a4677faf/lua/lazyvim/plugins/extras/editor/mini-files.lua
local function map_split(buf_id, lhs, direction, close_on_file)
local files = require "mini.files"
local should_close = close_on_file == nil and true or close_on_file
local rhs = function()
local cur_target = files.get_explorer_state().target_window
local new_target = vim.api.nvim_win_call(cur_target, function()
vim.cmd(direction .. " split")
return vim.api.nvim_get_current_win()
end)
files.set_target_window(new_target)
files.go_in { close_on_file = should_close }
end
local desc = "Open in " .. direction .. " split"
if should_close then desc = desc .. " and close" end
vim.keymap.set("n", lhs, rhs, { buffer = buf_id, desc = desc })
end
return {
"nvim-mini/mini.files",
dependencies = {
{
"AstroNvim/astrocore",
opts = {
mappings = {
n = {
["<Leader>e"] = {
function()
if not require("mini.files").close() then require("mini.files").open() end
end,
desc = "Explorer",
},
},
},
},
},
},
specs = {
{ "neo-tree.nvim", optional = true, enabled = false },
{
"catppuccin",
optional = true,
---@type CatppuccinOptions
opts = { integrations = { mini = true } },
},
{
"AstroNvim/astrolsp",
optional = true,
specs = {
{
"AstroNvim/astrocore",
---@type AstroCoreOpts
opts = {
autocmds = {
mini_files_lsp_operations = {
{
event = "User",
pattern = "MiniFilesBufferCreate",
desc = "Create mappings to modify target window via split",
callback = function(args)
local buf_id = args.data.buf_id
map_split(buf_id, "<C-w>s", "belowright horizontal")
map_split(buf_id, "<C-w>v", "belowright vertical")
map_split(buf_id, "<C-w>t", "tab")
map_split(buf_id, "<C-w>S", "belowright horizontal", false)
map_split(buf_id, "<C-w>V", "belowright vertical", false)
map_split(buf_id, "<C-w>T", "tab", false)
end,
},
{
event = "User",
pattern = "MiniFilesActionCreate",
desc = "execute `didCreateFiles` operation when creating files",
callback = function(args) require("astrolsp.file_operations").didCreateFiles(args.data.to) end,
},
{
event = "User",
pattern = "MiniFilesActionDelete",
desc = "execute `didDeleteFiles` operation when deleting files",
callback = function(args) require("astrolsp.file_operations").didDeleteFiles(args.data.from) end,
},
{
event = "User",
pattern = { "MiniFilesActionMove", "MiniFilesActionRename" },
desc = "execute `didRenameFiles` operation when moving or renaming files",
callback = function(args) require("astrolsp.file_operations").didRenameFiles(args.data) end,
},
},
},
},
},
},
},
},
opts = {},
}