nvim: Stuff
This commit is contained in:
@ -4,115 +4,115 @@ local codelldb_bin = "/usr/bin/codelldb"
|
||||
|
||||
-- Rust, C++, C
|
||||
dap.adapters.codelldb = {
|
||||
type = 'server',
|
||||
port = "${port}",
|
||||
executable = {
|
||||
command = codelldb_bin,
|
||||
args = {"--port", "${port}"},
|
||||
}
|
||||
type = 'server',
|
||||
port = "${port}",
|
||||
executable = {
|
||||
command = codelldb_bin,
|
||||
args = { "--port", "${port}" },
|
||||
}
|
||||
}
|
||||
|
||||
local function get_default_rust_program_path()
|
||||
local workspace = vim.fn.getcwd()
|
||||
local program_name = vim.fn.fnamemodify(workspace, ":t")
|
||||
return workspace .. '/target/debug/' .. program_name
|
||||
local workspace = vim.fn.getcwd()
|
||||
local program_name = vim.fn.fnamemodify(workspace, ":t")
|
||||
return workspace .. '/target/debug/' .. program_name
|
||||
end
|
||||
|
||||
dap.configurations.cpp = {
|
||||
{
|
||||
port = 1234,
|
||||
host = '127.0.0.1',
|
||||
name = "Attach to name",
|
||||
type = "codelldb",
|
||||
request = "attach",
|
||||
pid = function()
|
||||
-- Lets user enter the name of a running process instead of looking up the pid themselves
|
||||
local name = vim.fn.input('Enter pidof name: ')
|
||||
local handle = io.popen("pidof " .. name)
|
||||
local pid = handle:read("*a")
|
||||
handle:close()
|
||||
{
|
||||
port = 1234,
|
||||
host = '127.0.0.1',
|
||||
name = "Attach to name",
|
||||
type = "codelldb",
|
||||
request = "attach",
|
||||
pid = function()
|
||||
-- Lets user enter the name of a running process instead of looking up the pid themselves
|
||||
local name = vim.fn.input('Enter pidof name: ')
|
||||
local handle = io.popen("pidof " .. name)
|
||||
local pid = handle:read("*a")
|
||||
handle:close()
|
||||
|
||||
-- Trim the result
|
||||
pid = pid:match( "^%s*(.-)%s*$" )
|
||||
return pid
|
||||
end,
|
||||
stopOnEntry = true,
|
||||
},
|
||||
{
|
||||
port = 1234,
|
||||
host = '127.0.0.1',
|
||||
name = "Attach to PID",
|
||||
type = "codelldb",
|
||||
request = "attach",
|
||||
pid = function()
|
||||
return tonumber(vim.fn.input('Enter PID: '))
|
||||
end,
|
||||
stopOnEntry = true,
|
||||
},
|
||||
{
|
||||
port = 1234,
|
||||
host = '127.0.0.1',
|
||||
name = "Manually launch file",
|
||||
type = "codelldb",
|
||||
request = "launch",
|
||||
program = function()
|
||||
return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
|
||||
end,
|
||||
cwd = '${workspaceFolder}',
|
||||
stopOnEntry = true,
|
||||
},
|
||||
{
|
||||
-- To debug programs that need to run as root you can run a remote lldb-server as root
|
||||
-- sudo lldb-server platform --server --listen '*:1234'
|
||||
name = "Remote attach to name",
|
||||
type = "codelldb",
|
||||
request = "attach",
|
||||
pid = function()
|
||||
-- Lets user enter the name of a running process instead of looking up the pid themselves
|
||||
local name = vim.fn.input('Enter pidof name: ')
|
||||
local handle = io.popen("pidof " .. name)
|
||||
local pid = handle:read("*a")
|
||||
handle:close()
|
||||
-- Trim the result
|
||||
pid = pid:match("^%s*(.-)%s*$")
|
||||
return pid
|
||||
end,
|
||||
stopOnEntry = true,
|
||||
},
|
||||
{
|
||||
port = 1234,
|
||||
host = '127.0.0.1',
|
||||
name = "Attach to PID",
|
||||
type = "codelldb",
|
||||
request = "attach",
|
||||
pid = function()
|
||||
return tonumber(vim.fn.input('Enter PID: '))
|
||||
end,
|
||||
stopOnEntry = true,
|
||||
},
|
||||
{
|
||||
port = 1234,
|
||||
host = '127.0.0.1',
|
||||
name = "Manually launch file",
|
||||
type = "codelldb",
|
||||
request = "launch",
|
||||
program = function()
|
||||
return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
|
||||
end,
|
||||
cwd = '${workspaceFolder}',
|
||||
stopOnEntry = true,
|
||||
},
|
||||
{
|
||||
-- To debug programs that need to run as root you can run a remote lldb-server as root
|
||||
-- sudo lldb-server platform --server --listen '*:1234'
|
||||
name = "Remote attach to name",
|
||||
type = "codelldb",
|
||||
request = "attach",
|
||||
pid = function()
|
||||
-- Lets user enter the name of a running process instead of looking up the pid themselves
|
||||
local name = vim.fn.input('Enter pidof name: ')
|
||||
local handle = io.popen("pidof " .. name)
|
||||
local pid = handle:read("*a")
|
||||
handle:close()
|
||||
|
||||
-- Trim the result
|
||||
pid = pid:match( "^%s*(.-)%s*$" )
|
||||
return pid
|
||||
end,
|
||||
initCommands = {
|
||||
"platform select remote-linux",
|
||||
"platform connect connect://127.0.0.1:1234",
|
||||
"settings set target.inherit-env false",
|
||||
},
|
||||
},
|
||||
{
|
||||
-- To debug programs that need to run as root you can run a remote lldb-server as root
|
||||
-- sudo lldb-server platform --server --listen '*:1234'
|
||||
name = "Remote launch",
|
||||
type = "codelldb",
|
||||
request = "launch",
|
||||
program = function()
|
||||
return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
|
||||
end,
|
||||
initCommands = {
|
||||
"platform select remote-linux",
|
||||
"platform connect connect://127.0.0.1:1234",
|
||||
"settings set target.inherit-env false",
|
||||
},
|
||||
},
|
||||
-- Trim the result
|
||||
pid = pid:match("^%s*(.-)%s*$")
|
||||
return pid
|
||||
end,
|
||||
initCommands = {
|
||||
"platform select remote-linux",
|
||||
"platform connect connect://127.0.0.1:1234",
|
||||
"settings set target.inherit-env false",
|
||||
},
|
||||
},
|
||||
{
|
||||
-- To debug programs that need to run as root you can run a remote lldb-server as root
|
||||
-- sudo lldb-server platform --server --listen '*:1234'
|
||||
name = "Remote launch",
|
||||
type = "codelldb",
|
||||
request = "launch",
|
||||
program = function()
|
||||
return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
|
||||
end,
|
||||
initCommands = {
|
||||
"platform select remote-linux",
|
||||
"platform connect connect://127.0.0.1:1234",
|
||||
"settings set target.inherit-env false",
|
||||
},
|
||||
},
|
||||
}
|
||||
dap.configurations.c = dap.configurations.cpp
|
||||
dap.configurations.rust = dap.configurations.cpp
|
||||
|
||||
-- Insert this config as a rust specific one before the C++ configs
|
||||
table.insert(dap.configurations.rust, 1, {
|
||||
port = 1234,
|
||||
host = '127.0.0.1',
|
||||
name = "Launch Default Rust Program",
|
||||
type = "codelldb",
|
||||
request = "launch",
|
||||
program = get_default_rust_program_path,
|
||||
cwd = '${workspaceFolder}',
|
||||
stopOnEntry = true,
|
||||
port = 1234,
|
||||
host = '127.0.0.1',
|
||||
name = "Launch Default Rust Program",
|
||||
type = "codelldb",
|
||||
request = "launch",
|
||||
program = get_default_rust_program_path,
|
||||
cwd = '${workspaceFolder}',
|
||||
stopOnEntry = true,
|
||||
})
|
||||
|
||||
-- Python
|
||||
|
||||
Reference in New Issue
Block a user