adding telescope to pick bin to debug
This commit is contained in:
parent
aaa7a8558d
commit
ab6af8750d
|
@ -69,12 +69,34 @@ return {
|
||||||
type = 'lldb',
|
type = 'lldb',
|
||||||
request = 'launch',
|
request = 'launch',
|
||||||
program = function()
|
program = function()
|
||||||
local debug_bin = vim.fn.getcwd() .. '/build/debug/cpp-hello'
|
local pickers = require 'telescope.pickers'
|
||||||
if vim.fn.filereadable(debug_bin) == 1 then
|
local finders = require 'telescope.finders'
|
||||||
return debug_bin
|
local conf = require('telescope.config').values
|
||||||
else
|
local entry_maker = function(entry)
|
||||||
-- return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
|
return {
|
||||||
|
value = entry,
|
||||||
|
display = entry,
|
||||||
|
ordinal = entry,
|
||||||
|
}
|
||||||
end
|
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,
|
end,
|
||||||
cwd = '${workspaceFolder}',
|
cwd = '${workspaceFolder}',
|
||||||
stopOnEntry = false,
|
stopOnEntry = false,
|
||||||
|
|
Loading…
Reference in New Issue