From 035bb1e6c592c72c72678a52ac96ca393043cdd2 Mon Sep 17 00:00:00 2001 From: Felix Rath Date: Fri, 6 Dec 2024 11:55:19 +0100 Subject: [PATCH] fix(rust): Only use mason.nvim if it is present Thanks @dpetka2001 for the snippet! --- lua/lazyvim/plugins/extras/lang/rust.lua | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/lua/lazyvim/plugins/extras/lang/rust.lua b/lua/lazyvim/plugins/extras/lang/rust.lua index b01a61ff..eec3ce2d 100644 --- a/lua/lazyvim/plugins/extras/lang/rust.lua +++ b/lua/lazyvim/plugins/extras/lang/rust.lua @@ -97,16 +97,18 @@ return { }, }, config = function(_, opts) - local package_path = require("mason-registry").get_package("codelldb"):get_install_path() - local codelldb = package_path .. "/extension/adapter/codelldb" - local library_path = package_path .. "/extension/lldb/lib/liblldb.dylib" - local uname = io.popen("uname"):read("*l") - if uname == "Linux" then - library_path = package_path .. "/extension/lldb/lib/liblldb.so" + if LazyVim.has("mason.nvim") then + local package_path = require("mason-registry").get_package("codelldb"):get_install_path() + local codelldb = package_path .. "/extension/adapter/codelldb" + local library_path = package_path .. "/extension/lldb/lib/liblldb.dylib" + local uname = io.popen("uname"):read("*l") + 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 - 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 {}) if vim.fn.executable("rust-analyzer") == 0 then LazyVim.error(