I am using nvim and nvim-dap for debugging, in particular with Rust. I would like to make use of rust's pretty printers for lldb while debugging in nvim.
Rust provides some pretty printers here:
which allow me to start lldb
like this:
script_import="command script import ~/Apps/rust-lldb/lldb_lookup.py"
commands_file="~/Apps/rust-lldb/lldb_commands"
lldb --one-line-before-file "$script_import" --source-before-file "$commands_file" "$@"
And this works, allowing me to debug with a pretty printer.
The problem is that nvim-dap needs some dap server, and the only way I've found to create this is with the lldb-dap
binary: .lldb-dap
But I have found no way to pass the --one-line-before-file, etc. arguments to lldb-dap, so that it loads in the pretty printers. It just seems to ignore these arguments.
My nvim-dap
configuration looks something like this:
dap.adapters.rust_lldb = {
type = "executable",
command = "lldb-dap-18",
name = "rust_lldb",
}
dap.configurations.rust = {
{
name = "Launch Rust Executable",
type = "rust_lldb",
request = "launch",
program = function()
return vim.fn.input({
prompt = "Path to executable: ",
default = vim.fn.getcwd() .. "/",
completion = "file",
})
end,
cwd = "${workspaceFolder}",
stopOnEntry = false,
args = {},
},
}
So how can I run lldb-dap with these pretty printers, so that I can pretty print variables in nvim?
I am using nvim and nvim-dap for debugging, in particular with Rust. I would like to make use of rust's pretty printers for lldb while debugging in nvim.
Rust provides some pretty printers here: https://github/rust-lang/rust/tree/master/src/etc
which allow me to start lldb
like this:
script_import="command script import ~/Apps/rust-lldb/lldb_lookup.py"
commands_file="~/Apps/rust-lldb/lldb_commands"
lldb --one-line-before-file "$script_import" --source-before-file "$commands_file" "$@"
And this works, allowing me to debug with a pretty printer.
The problem is that nvim-dap needs some dap server, and the only way I've found to create this is with the lldb-dap
binary: https://marketplace.visualstudio/items?itemName=llvm-vs-code-extensions.lldb-dap
But I have found no way to pass the --one-line-before-file, etc. arguments to lldb-dap, so that it loads in the pretty printers. It just seems to ignore these arguments.
My nvim-dap
configuration looks something like this:
dap.adapters.rust_lldb = {
type = "executable",
command = "lldb-dap-18",
name = "rust_lldb",
}
dap.configurations.rust = {
{
name = "Launch Rust Executable",
type = "rust_lldb",
request = "launch",
program = function()
return vim.fn.input({
prompt = "Path to executable: ",
default = vim.fn.getcwd() .. "/",
completion = "file",
})
end,
cwd = "${workspaceFolder}",
stopOnEntry = false,
args = {},
},
}
So how can I run lldb-dap with these pretty printers, so that I can pretty print variables in nvim?
Share Improve this question asked Mar 16 at 18:21 TudorTudor 1571 silver badge4 bronze badges1 Answer
Reset to default 0lldb-dap will source (using command source
) a file called .lldbinit in your home directory. So you can put your command source
statements in there and they will get automatically added to your session.
This does get sourced before any file arguments you the input file is processed, so it will be the equivalent of what you were doing on the command line, though that doesn't really matter for data formatters.