@@ -345,38 +345,51 @@ local RustaceanDefaultConfig = {
345345 }
346346 else
347347 local has_mason , mason_registry = pcall (require , ' mason-registry' )
348- if has_mason and mason_registry .is_installed (' codelldb' ) then
349- local codelldb_package = mason_registry .get_package (' codelldb' )
350- local mason_codelldb_path
351- if require (' mason.version' ).MAJOR_VERSION > 1 then
352- mason_codelldb_path =
353- vim .fs .joinpath (vim .fn .expand (' $MASON' ), ' packages' , codelldb_package .name , ' extension' )
348+ local ok , err = pcall (function ()
349+ if has_mason and mason_registry .is_installed (' codelldb' ) then
350+ local codelldb_package = mason_registry .get_package (' codelldb' )
351+ local mason_codelldb_path
352+ if require (' mason.version' ).MAJOR_VERSION > 1 then
353+ mason_codelldb_path =
354+ vim .fs .joinpath (vim .fn .expand (' $MASON' ), ' packages' , codelldb_package .name , ' extension' )
355+ else
356+ mason_codelldb_path = vim .fs .joinpath (codelldb_package :get_install_path (), ' extension' )
357+ end
358+ local codelldb_path = vim .fs .joinpath (mason_codelldb_path , ' adapter' , ' codelldb' )
359+ local liblldb_path = vim .fs .joinpath (mason_codelldb_path , ' lldb' , ' lib' , ' liblldb' )
360+ local shell = require (' rustaceanvim.shell' )
361+ if shell .is_windows () then
362+ codelldb_path = codelldb_path .. ' .exe'
363+ liblldb_path = vim .fs .joinpath (mason_codelldb_path , ' lldb' , ' bin' , ' liblldb.dll' )
364+ else
365+ liblldb_path = liblldb_path .. (shell .is_macos () and ' .dylib' or ' .so' )
366+ end
367+ result = config .get_codelldb_adapter (codelldb_path , liblldb_path )
354368 else
355- mason_codelldb_path = vim .fs .joinpath (codelldb_package :get_install_path (), ' extension' )
369+ local has_lldb_dap = vim .fn .executable (' lldb-dap' ) == 1
370+ local has_lldb_vscode = vim .fn .executable (' lldb-vscode' ) == 1
371+ if not has_lldb_dap and not has_lldb_vscode then
372+ return result
373+ end
374+ local command = has_lldb_dap and ' lldb-dap' or ' lldb-vscode'
375+ --- @cast result rustaceanvim.dap.executable.Config
376+ result = {
377+ type = ' executable' ,
378+ command = exepath_or_binary (command ),
379+ name = ' lldb' ,
380+ }
356381 end
357- local codelldb_path = vim .fs .joinpath (mason_codelldb_path , ' adapter' , ' codelldb' )
358- local liblldb_path = vim .fs .joinpath (mason_codelldb_path , ' lldb' , ' lib' , ' liblldb' )
359- local shell = require (' rustaceanvim.shell' )
360- if shell .is_windows () then
361- codelldb_path = codelldb_path .. ' .exe'
362- liblldb_path = vim .fs .joinpath (mason_codelldb_path , ' lldb' , ' bin' , ' liblldb.dll' )
363- else
364- liblldb_path = liblldb_path .. (shell .is_macos () and ' .dylib' or ' .so' )
365- end
366- result = config .get_codelldb_adapter (codelldb_path , liblldb_path )
367- else
368- local has_lldb_dap = vim .fn .executable (' lldb-dap' ) == 1
369- local has_lldb_vscode = vim .fn .executable (' lldb-vscode' ) == 1
370- if not has_lldb_dap and not has_lldb_vscode then
371- return result
372- end
373- local command = has_lldb_dap and ' lldb-dap' or ' lldb-vscode'
374- --- @cast result rustaceanvim.dap.executable.Config
375- result = {
376- type = ' executable' ,
377- command = exepath_or_binary (command ),
378- name = ' lldb' ,
379- }
382+ end )
383+ if not ok then
384+ vim .schedule (function ()
385+ vim .notify (
386+ ([[
387+ mason.nvim threw an error while trying to detect codelldb:
388+ %s
389+ ]] ):format (err ),
390+ vim .log .levels .WARN
391+ )
392+ end )
380393 end
381394 end
382395 return result
0 commit comments