-
-
Notifications
You must be signed in to change notification settings - Fork 75
Closed
Description
Hello. Look at this function that creates a simple menu:
function nvim_settings.on_menu_item_selected(item, index)
local file = io.open(project_settings, 'r')
local content = {}
for line in file:lines() do
table.insert (content, line)
end
io.close(file)
content[index] = item.text
file = io.open(project_settings, 'w')
for index, value in ipairs(content) do
file:write(value..'\n')
end
io.close(file)
local notification_title = string.format("%s selected", item.text)
require("notify").notify(notification_title, "INFO",
{ title = txt_build_type, timeout = notify_done_title })
end
function nvim_settings.select_arch_type(title)
local menu = Menu({
position = { row = "5%", col = "50%" },
size = { width = 40, height = 2 },
relative = "editor",
border = {
highlight = "MyHighlightGroup",
style = "single",
text = {
top = title,
top_align = "center",
},
},
win_options = { winblend = 10, winhighlight = "Normal:Normal" },
},
{
lines = {
Menu.item("x86"),
Menu.item("x64"),
},
max_width = 20,
keymap = {
focus_next = { "j", "<Down>", "<Tab>" },
focus_prev = { "k", "<Up>", "<S-Tab>" },
close = { "<Esc>", "<C-c>" },
submit = { "<CR>", "<Space>" },
},
on_submit = function(item)
nvim_settings.on_menu_item_selected(item, 1)
end,
})
menu:mount()
menu:on(event.BufLeave, menu.menu_props.on_close, { once = true })
end
I want to pass a table to select_arch_type() that contains items of Menu, Instead of doing something like this:
...
lines = {
Menu.item("x86"),
Menu.item("x64"),
},
...
How do that?
Metadata
Metadata
Assignees
Labels
No labels