fix(rust): Only use mason.nvim if it is present

Thanks @dpetka2001 for the snippet!
This commit is contained in:
Felix Rath 2024-12-06 11:55:19 +01:00
parent 8a3321d827
commit 035bb1e6c5

View file

@ -97,16 +97,18 @@ return {
}, },
}, },
config = function(_, opts) config = function(_, opts)
local package_path = require("mason-registry").get_package("codelldb"):get_install_path() if LazyVim.has("mason.nvim") then
local codelldb = package_path .. "/extension/adapter/codelldb" local package_path = require("mason-registry").get_package("codelldb"):get_install_path()
local library_path = package_path .. "/extension/lldb/lib/liblldb.dylib" local codelldb = package_path .. "/extension/adapter/codelldb"
local uname = io.popen("uname"):read("*l") local library_path = package_path .. "/extension/lldb/lib/liblldb.dylib"
if uname == "Linux" then local uname = io.popen("uname"):read("*l")
library_path = package_path .. "/extension/lldb/lib/liblldb.so" if uname == "Linux" then
library_path = package_path .. "/extension/lldb/lib/liblldb.so"
end
opts.dap = {
adapter = require("rustaceanvim.config").get_codelldb_adapter(codelldb, library_path),
}
end end
opts.dap = {
adapter = require("rustaceanvim.config").get_codelldb_adapter(codelldb, library_path),
}
vim.g.rustaceanvim = vim.tbl_deep_extend("keep", vim.g.rustaceanvim or {}, opts or {}) vim.g.rustaceanvim = vim.tbl_deep_extend("keep", vim.g.rustaceanvim or {}, opts or {})
if vim.fn.executable("rust-analyzer") == 0 then if vim.fn.executable("rust-analyzer") == 0 then
LazyVim.error( LazyVim.error(