broke the tele picker, fix pt 2
This commit is contained in:
parent
8a51315db4
commit
a5b0da62c1
|
@ -55,7 +55,6 @@ return {
|
||||||
},
|
},
|
||||||
config = function()
|
config = function()
|
||||||
local dap = require 'dap'
|
local dap = require 'dap'
|
||||||
local utils = require 'custom.utils'
|
|
||||||
|
|
||||||
-- Configure the LLDB DAP adapter for C/C++
|
-- Configure the LLDB DAP adapter for C/C++
|
||||||
-- Assumes 'lldb-dap' executable is in PATH (from pkgs.llvmPackages_XX.lldb)
|
-- Assumes 'lldb-dap' executable is in PATH (from pkgs.llvmPackages_XX.lldb)
|
||||||
|
@ -71,7 +70,7 @@ return {
|
||||||
type = 'lldb',
|
type = 'lldb',
|
||||||
request = 'launch',
|
request = 'launch',
|
||||||
program = function()
|
program = function()
|
||||||
return utils.pick_executable_for_dap(vim.fn.getcwd() .. '/build')
|
return require('custom.utils').pick_executable(vim.fn.getcwd() .. '/build')
|
||||||
end,
|
end,
|
||||||
cwd = '${workspaceFolder}',
|
cwd = '${workspaceFolder}',
|
||||||
stopOnEntry = false,
|
stopOnEntry = false,
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
local async = require 'plenary.async.util'
|
local async = require 'plenary.async'
|
||||||
local pickers = require 'telescope.pickers'
|
local pickers = require 'telescope.pickers'
|
||||||
local finders = require 'telescope.finders'
|
local finders = require 'telescope.finders'
|
||||||
local sorters = require('telescope.config').values
|
local sorters = require('telescope.config').values
|
||||||
|
@ -18,7 +18,8 @@ local function collect_executables(start_dir)
|
||||||
return results
|
return results
|
||||||
end
|
end
|
||||||
|
|
||||||
local function pick_executable(start_dir, on_choice)
|
local function pick_executable(start_dir)
|
||||||
|
return async.wrap(function(start_dir, on_choice)
|
||||||
local executables = collect_executables(start_dir)
|
local executables = collect_executables(start_dir)
|
||||||
if #executables == 0 then
|
if #executables == 0 then
|
||||||
vim.notify('No executables found in ' .. start_dir, vim.log.levels.WARN)
|
vim.notify('No executables found in ' .. start_dir, vim.log.levels.WARN)
|
||||||
|
@ -35,36 +36,23 @@ local function pick_executable(start_dir, on_choice)
|
||||||
actions.select_default:replace(function(prompt_bufnr)
|
actions.select_default:replace(function(prompt_bufnr)
|
||||||
local entry = action_state.get_selected_entry()
|
local entry = action_state.get_selected_entry()
|
||||||
actions.close(prompt_bufnr)
|
actions.close(prompt_bufnr)
|
||||||
on_result(entry.value)
|
on_choice(entry.value)
|
||||||
end)
|
end)
|
||||||
map('i', '<Esc>', function(buf)
|
map('i', '<Esc>', function(buf)
|
||||||
actions.close(buf)
|
actions.close(buf)
|
||||||
on_result(nil)
|
on_choice(nil)
|
||||||
end)
|
end)
|
||||||
map('n', 'q', function(buf)
|
map('n', 'q', function(buf)
|
||||||
actions.close(buf)
|
actions.close(buf)
|
||||||
on_result(nil)
|
on_choice(nil)
|
||||||
end)
|
end)
|
||||||
return true
|
return true
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
:find()
|
:find()
|
||||||
end
|
end, 2)(start_dir)
|
||||||
|
|
||||||
local function pick_executable_for_dap(start_dir)
|
|
||||||
return async.void(function()
|
|
||||||
local co = coroutine.running()
|
|
||||||
pick_executable(start_dir, function(choice)
|
|
||||||
coroutine.resume(co, choice)
|
|
||||||
end)
|
|
||||||
local result = coroutine.yield()
|
|
||||||
if not result then
|
|
||||||
vim.notify('Debug launch cancelled', vim.log.levels.INFO)
|
|
||||||
end
|
|
||||||
return result
|
|
||||||
end)()
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return {
|
return {
|
||||||
pick_executable_for_dap = pick_executable_for_dap,
|
pick_executable = pick_executable,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue