forked from nvim-java/nvim-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathui.lua
More file actions
40 lines (33 loc) · 854 Bytes
/
ui.lua
File metadata and controls
40 lines (33 loc) · 854 Bytes
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
local async = require('java-core.utils.async')
local await = async.wait
local notify = require('java-core.utils.notify')
local M = {}
function M.select(prompt, values)
return await(function(callback)
vim.ui.select(values, {
prompt = prompt,
}, callback)
end)
end
---@param configs table
function M.select_from_dap_configs(configs)
local config_names = {}
local config_lookup = {}
for _, config in ipairs(configs) do
if config.projectName then
table.insert(config_names, config.name)
config_lookup[config.name] = config
end
end
if #config_names == 0 then
notify.warn('Config not found')
return
end
if #config_names == 1 then
return config_lookup[config_names[1]]
end
local selected_config =
M.select('Select the main class (modul -> mainClass)', config_names)
return config_lookup[selected_config]
end
return M