Skip to content

Commit

Permalink
fix(dap): validate custom DAP client configs (#670)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrcjkb authored Jan 28, 2025
1 parent aed4dab commit ca7e678
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions lua/rustaceanvim/dap.lua
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,20 @@ function M.start(args, verbose, callback, on_error)
local final_config = local_config ~= false and vim.deepcopy(local_config) or vim.deepcopy(dap_config)
--- @cast final_config rustaceanvim.dap.client.Config

local err
ok, err = pcall(vim.validate, {
type = { final_config.type, 'string' },
name = { final_config.name, 'string' },
request = { final_config.request, 'string' },
})
if not ok then
on_error(([[
DAP client config validation failed.
%s
If you have specified a custom configuration, see ":h rustaceanvim.dap.client.Config".
]]):format(err))
return
end
if dap.adapters[final_config.type] == nil then
on_error('No adapter exists named "' .. final_config.type .. '". See ":h dap-adapter" for more information')
return
Expand Down

0 comments on commit ca7e678

Please sign in to comment.