refactored binary picker
This commit is contained in:
parent
ab6af8750d
commit
6455565e79
|
@ -68,36 +68,7 @@ return {
|
|||
name = 'Launch C/C++ (lldb-dap)',
|
||||
type = 'lldb',
|
||||
request = 'launch',
|
||||
program = function()
|
||||
local pickers = require 'telescope.pickers'
|
||||
local finders = require 'telescope.finders'
|
||||
local conf = require('telescope.config').values
|
||||
local entry_maker = function(entry)
|
||||
return {
|
||||
value = entry,
|
||||
display = entry,
|
||||
ordinal = entry,
|
||||
}
|
||||
end
|
||||
|
||||
local co = coroutine.running()
|
||||
pickers
|
||||
.new({}, {
|
||||
prompt_title = 'Select binary',
|
||||
finder = finders.new_oneshot_job { 'fd', '--type=f', '', 'build/debug', 'build/release' },
|
||||
sorter = conf.generic_sorter {},
|
||||
attach_mappings = function(_, map)
|
||||
map('i', '<CR>', function(bufnr)
|
||||
local entry = require('telescope.actions.state').get_selected_entry()
|
||||
require('telescope.actions').close(bufnr)
|
||||
coroutine.resume(co, entry.value)
|
||||
end)
|
||||
return true
|
||||
end,
|
||||
})
|
||||
:find()
|
||||
return coroutine.yield()
|
||||
end,
|
||||
program = require('custom.utils').pick_executable,
|
||||
cwd = '${workspaceFolder}',
|
||||
stopOnEntry = false,
|
||||
args = {},
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
return {
|
||||
pick_executable = function()
|
||||
local pickers = require 'telescope.pickers'
|
||||
local finders = require 'telescope.finders'
|
||||
local conf = require('telescope.config').values
|
||||
|
||||
local entry_maker = function(entry)
|
||||
return {
|
||||
value = entry,
|
||||
display = entry,
|
||||
ordinal = entry,
|
||||
}
|
||||
end
|
||||
|
||||
local co = coroutine.running()
|
||||
pickers
|
||||
.new({}, {
|
||||
prompt_title = 'Select binary',
|
||||
finder = finders.new_oneshot_job {
|
||||
'fd',
|
||||
'--type',
|
||||
'f',
|
||||
'--exec-batch',
|
||||
'test',
|
||||
'-x',
|
||||
'{}',
|
||||
';',
|
||||
'echo',
|
||||
'{}',
|
||||
'',
|
||||
'build/',
|
||||
},
|
||||
sorter = conf.generic_sorter {},
|
||||
attach_mappings = function(_, map)
|
||||
map('i', '<CR>', function(bufnr)
|
||||
local entry = require('telescope.actions.state').get_selected_entry()
|
||||
require('telescope.actions').close(bufnr)
|
||||
coroutine.resume(co, entry.value)
|
||||
end)
|
||||
return true
|
||||
end,
|
||||
})
|
||||
:find()
|
||||
return coroutine.yield()
|
||||
end,
|
||||
}
|
Loading…
Reference in New Issue