-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmenu.lua
More file actions
137 lines (128 loc) · 2.68 KB
/
Copy pathmenu.lua
File metadata and controls
137 lines (128 loc) · 2.68 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
-- SPDX-FileCopyrightText: 2026 Elouan Martinet <exa@elou.world>
-- SPDX-License-Identifier: BSD-3-Clause
-- AI-usage disclosure: some parts of this file were written by an AI model
local Menu = require("nui.menu")
local event = require("nui.utils.autocmd").event
local M = {}
function M.open()
local function toggle_highlights()
if vim.v.hlsearch == 1 then
vim.cmd("nohlsearch")
else
vim.cmd("set hlsearch")
end
end
local lines = {
Menu.item("Search highlights", {
action = toggle_highlights,
}),
Menu.separator(" Fzf Lua "),
Menu.item("Resume", {
action = function()
vim.cmd("FzfLua resume")
end
}),
Menu.item("Live Grep", {
action = function()
vim.cmd("FzfLua live_grep")
end
}),
Menu.item("Grep word", {
action = function()
vim.cmd("FzfLua grep_cword")
end
}),
Menu.item("Files", {
action = function()
vim.cmd("FzfLua files")
end
}),
Menu.item("Buffers", {
action = function()
vim.cmd("FzfLua buffers sort_lastused=false")
end
}),
Menu.item("Tabs", {
action = function()
vim.cmd("FzfLua tabs fzf_opts.--header-lines=1")
end
}),
Menu.item("Buffers in tab", {
action = function()
vim.cmd("FzfLua tabs current_tab_only=true")
end
}),
Menu.item("LSP Diagnostics", {
action = function()
vim.cmd("FzfLua lsp_document_diagnostics")
end
}),
Menu.separator(" Git "),
Menu.item("Git diff", {
action = function()
vim.cmd("DiffviewOpen")
end
}),
Menu.item("Git blame", {
action = function()
vim.cmd("Gitsigns blame")
end
}),
Menu.separator(" Other "),
Menu.item("Keep only this tab", {
action = function()
vim.cmd("tabonly")
end,
}),
Menu.item("Guess indent", {
action = function()
vim.cmd("GuessIndent silent")
end,
}),
Menu.item("IDE mode", {
action = function()
require("config.ide").toggle()
end,
}),
Menu.item("Terminal", {
action = function()
require("config.terminal").open()
end,
}),
}
local menu = Menu({
position = "50%",
size = {
width = 32,
height = math.max(2,
math.min(#lines, vim.o.lines - 6)),
},
border = {
style = "rounded",
text = { top = " Leader ", top_align = "center" },
},
win_options = {
winhighlight = "Normal:Normal,FloatBorder:FloatBorder",
cursorline = true,
},
},
{
lines = lines,
keymap = {
focus_next = { "j", "<Down>", "<Tab>" },
focus_prev = { "k", "<Up>", "<S-Tab>" },
close = { "<Esc>", "<C-c>" },
submit = { "<CR>", "<Space>" },
},
on_submit = function(item)
if item.action then
item.action()
end
end,
})
menu:mount()
menu:on(event.BufLeave, function()
menu:unmount()
end)
end
return M