Closed TornaxO7 closed 1 year ago
have you solved this?
Sadly not :(
by naming the configuration as the plugin wants the problem gets solved
dap.configurations.rust = {{
name = 'Launch file',
type = 'rt_lldb',
request = 'launch',
program =
function()
return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
end,
cwd = '${workspaceFolder}',
stopOnEntry = false,
args = {},
}}
I had the same issue. I tried changing line 131 in dap.lua
from type = "rt_lld"
to type = "rust"
, that solved it for me but I did not want to change the plugin source code. So I did more digging and figured out that I had to change my call to the setup function of rust-tools, and include this:
dap = {
adapter = require("rust-tools.dap").get_codelldb_adapter(codelldb_path, liblldb_path)
}
In dap.lua
dap.adapters.rt_lldb
will be set to whatever rt.config.options.dap.adapter
is set to (which is where the stuff above ends up in).
So my complete call to setup()
for rust-tools now looks like this (I use mason to handle LSP servers):
local rt = require("rust-tools")
local mason_registry = require("mason-registry")
local codelldb_root = mason_registry.get_package("codelldb"):get_install_path() .. "/extension/"
local codelldb_path = codelldb_root .. "adapter/codelldb"
local liblldb_path = codelldb_root .. "lldb/lib/liblldb.so"
local opts = {
server = {
on_attach = function(_, bufnr)
-- Rust specific keymaps
local wk = require('which-key')
wk.register({
r = {
name = "Rust",
-- Hover actions
h = { rt.hover_actions.hover_actions, "Hover Actions", buffer = bufnr },
-- Code action groups
a = { rt.code_action_group.code_action_group, "Code Action", buffer = bufnr },
-- Display runnables (run, test, check etc)
r = { vim.cmd.RustRunnables, "Runnables" },
-- Display debuggables (run, test, check etc)
d = { vim.cmd.RustDebuggables, "Runnables" },
}
}, { prefix = "<leader>" })
-- Add generic shortcuts
custom_on_attach(_, bufnr)
end,
},
dap = {
adapter = require("rust-tools.dap").get_codelldb_adapter(codelldb_path, liblldb_path)
}
}
rt.setup(opts)
@iceaway May I ask where you got this line from?
local mason_registry = require("mason-registry")
I can't find mason-registry
in the docs of mason
.
Wait, it works now. Yaaaaaaaaaaay
Thank you for your answer @iceaway it works and thank you for the trick with mason-registry
!
Wait, it works now. Yaaaaaaaaaaay
Thank you for your answer @iceaway it works and thank you for the trick with
mason-registry
!
Glad I could help! Not entirely sure where I got that line from, I came across it when I was looking for solutions.
I'm getting the following error, if I run:
RustDebuggables
. What do I have to do to fix this?This is how I start rust tools: