1
0
Fork 0

dap: add lldb for rust

This commit is contained in:
Felipe 2023-11-19 19:28:24 -03:00
parent 148b8dd4ea
commit 90e655005c
Signed by: pitbuster
SSH key fingerprint: SHA256:HDYu2Pm4/TmSX8GBwV49UvFWr1Ljg8XlHxKeCpjJpOk

View file

@ -558,7 +558,7 @@ vim.keymap.set("n", "<Leader>s", telescope.extensions.luasnip.luasnip)
---- nvim-dap ---- nvim-dap
vim.g.dap_loaded = false vim.g.dap_loaded = false
vim.api.nvim_create_autocmd({ "FileType" }, { vim.api.nvim_create_autocmd({ "FileType" }, {
pattern = { "go" }, pattern = { "go", "rust" },
callback = function() callback = function()
vim.g.dap_loaded = true vim.g.dap_loaded = true
vim.cmd("packadd nvim-dap") vim.cmd("packadd nvim-dap")
@ -587,6 +587,46 @@ vim.api.nvim_create_autocmd({ "FileType" }, {
dap.listeners.before.event_exited["dapui_config"] = function() dap.listeners.before.event_exited["dapui_config"] = function()
dapui.close() dapui.close()
end end
-- rust
dap.adapters.lldb = {
type = 'executable',
command = '/usr/bin/lldb-vscode',
name = 'lldb'
}
dap.configurations.rust = {
{
name = 'Launch',
type = 'lldb',
request = 'launch',
program = function()
return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
end,
cwd = '${workspaceFolder}',
stopOnEntry = false,
args = {},
initCommands = function()
-- Find out where to look for the pretty printer Python module
local rustc_sysroot = vim.fn.trim(vim.fn.system('rustc --print sysroot'))
local script_import = 'command script import "' .. rustc_sysroot .. '/lib/rustlib/etc/lldb_lookup.py"'
local commands_file = rustc_sysroot .. '/lib/rustlib/etc/lldb_commands'
local commands = {}
local file = io.open(commands_file, 'r')
if file then
for line in file:lines() do
table.insert(commands, line)
end
file:close()
end
table.insert(commands, 1, script_import)
return commands
end,
},
}
-- nvim-dap-go -- nvim-dap-go
require("dap-go").setup() require("dap-go").setup()
end, end,