Dot_Files/.config/nvim/lua/plugins/configs/_dap.lua

59 lines
1.8 KiB
Lua
Raw Normal View History

2022-05-11 21:00:57 -05:00
local dap = require('dap')
local async = require('plenary.async')
2022-03-07 14:50:15 -06:00
--- Gets a path for a given program in the environment
---@param program @The string of a program in the PATH
---@return @The full path to the program if found, or nil if not
local function get_program_path(program)
2022-05-11 21:00:57 -05:00
local fd = io.popen('which ' .. program)
local program_path = fd:read('*all')
fd:close()
program_path = program_path.gsub(program_path, '\n', '')
2022-03-07 14:50:15 -06:00
2022-05-11 21:00:57 -05:00
if program_path == nil or program_path == '' then
vim.notify(('Failed to find (%s) in your path'):format(program), 'error', {
title = 'DAP',
})
2022-05-11 21:00:57 -05:00
program_path = nil
end
return program_path
2022-03-07 14:50:15 -06:00
end
2022-05-11 21:00:57 -05:00
local lldb_path = get_program_path('lldb-vscode')
2022-03-07 14:50:15 -06:00
-- Adapaters
dap.adapters.lldb = {
2022-05-11 21:00:57 -05:00
type = 'executable',
command = lldb_path,
name = 'lldb',
2022-03-07 14:50:15 -06:00
}
-- configurations
dap.configurations.cpp = {
2022-05-11 21:00:57 -05:00
{
name = 'Launch',
type = 'lldb',
request = 'launch',
program = function()
return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
end,
cwd = '${workspaceFolder}',
stopOnEntry = false,
targetArchitecture = 'arm64',
args = {},
2022-03-07 14:50:15 -06:00
2022-05-11 21:00:57 -05:00
-- if you change `runInTerminal` to true, you might need to change the yama/ptrace_scope setting:
--
-- echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope
--
-- Otherwise you might get the following error:
--
-- Error on launch: Failed to attach to the target process
--
-- But you should be aware of the implications:
-- https://www.kernel.org/doc/html/latest/admin-guide/LSM/Yama.html
runInTerminal = false,
},
2022-03-07 14:50:15 -06:00
}
dap.configurations.c = dap.configurations.cpp
2022-04-26 05:03:46 -05:00
dap.configurations.rust = dap.configurations.cpp