@@ -9,6 +9,7 @@ local maker = require("telescope.pickers.entry_display").create
99local xbase = require " xbase"
1010local watch = require " xbase.watch"
1111local themes = require " telescope.themes"
12+ local util = require " xbase.util"
1213
1314local mappings = function (_ , _ )
1415 action_set .select :replace (function (bufnr , direction )
5556
5657local get_selections = function (picker )
5758 local commands = picker == " Watch" and { " Build" , " Run" } or { picker }
58- local root = vim .loop .cwd ()
59- local info = vim .g .xbase .projects [root ]
60- if info == nil then
61- error " No info available"
62- end
63-
64- local targets = {}
59+ local project = vim .g .xbase .projects [vim .loop .cwd ()]
6560
66- -- TOOD(core): Support custom schemes
67- for name , _ in pairs (info .targets ) do
68- targets [# targets + 1 ] = name
61+ if project == nil then
62+ error " No project info found"
6963 end
7064
71- -- TOOD(core): Support custom project configurations
72- local configurations = { " Debug" , " Release" }
73-
74- local devices = {}
65+ local targets = util .get_targets_runners (project )
7566
76- if picker == " Run" or picker == " Watch" then
77- -- TODO(nvim): Only include devices that is actually supported by target
78- devices = vim .tbl_map (function (device )
79- return {
80- name = device .info .name ,
81- udid = device .info .udid ,
82- }
83- end , vim .g .xbase .devices )
84- end
67+ -- TOOD(core): Support custom project configurations and schemes
68+ local configurations = { " Debug" , " Release" }
8569
8670 local results = {}
8771
8872 for _ , command in ipairs (commands ) do
89- for _ , target in ipairs (targets ) do
73+ for _ , target_info in ipairs (targets ) do
74+ local target = target_info .name
75+ local devices = target_info .runners
76+ local include_devices = # devices ~= 0 and command == " Run"
77+
9078 for _ , configuration in ipairs (configurations ) do
91- if # devices ~= 0 and command == " Run " then
79+ if include_devices then
9280 for _ , device in ipairs (devices ) do
9381 insert_entry (results , picker , command , target , configuration , device )
9482 end
@@ -129,7 +117,7 @@ local entry_maker = function(entry)
129117 ti (parts , { entry .kind , " TSNone" })
130118 end
131119
132- ti (items , { width = 9 })
120+ ti (items , { width = 12 })
133121 entry .ordinal = string.format (" %s %s" , entry .ordinal , target )
134122 ti (parts , { target , " TSCharacter" })
135123
0 commit comments