-
-
Notifications
You must be signed in to change notification settings - Fork 217
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7b18c31
commit 5ba8cea
Showing
1 changed file
with
79 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
local M = {} | ||
|
||
---@param command string? | ||
local function check_executable(command) | ||
local health = vim.health | ||
if not command then | ||
health.error("Missing required `command` property") | ||
else | ||
if vim.fn.executable(command) ~= 1 then | ||
health.error(table.concat({ | ||
"`command` is not executable.", | ||
"Check path and permissions.", | ||
"Use vim.fn.expand to handle ~ or $HOME:\n ", | ||
command | ||
}, " ")) | ||
else | ||
health.ok("is executable: " .. command) | ||
end | ||
end | ||
end | ||
|
||
|
||
function M.check() | ||
local health = vim.health | ||
if not health or not health.start then | ||
return | ||
end | ||
health.start("dap: Adapters") | ||
local dap = require("dap") | ||
for t, adapter in pairs(dap.adapters) do | ||
health.start("dap.adapter: " .. t) | ||
if type(adapter) == "function" then | ||
health.info("Adapter is a function. Can't validate it") | ||
else | ||
if adapter.type == "executable" then | ||
adapter = adapter --[[@as ExecutableAdapter]] | ||
check_executable(adapter.command) | ||
elseif adapter.type == "server" then | ||
adapter = adapter --[[@as ServerAdapter]] | ||
if not adapter.port then | ||
health.error("Missing required `port` property") | ||
end | ||
if adapter.executable then | ||
check_executable(adapter.executable.command) | ||
end | ||
elseif adapter.type == "pipe" then | ||
adapter = adapter --[[@as PipeAdapter]] | ||
if not adapter.pipe then | ||
health.error("Missing required `pipe` property") | ||
end | ||
else | ||
health.error(adapter.type .. " must be one of: executable, server or pipe") | ||
end | ||
end | ||
end | ||
|
||
health.start("dap: Sessions") | ||
local sessions = dap.sessions() | ||
if not next(sessions) then | ||
health.ok("No active sessions") | ||
else | ||
for _, session in pairs(sessions) do | ||
if session.initialized then | ||
health.ok(" id: " .. session.id .. "\n type: " .. session.config.type) | ||
else | ||
health.warn(table.concat({ | ||
"\n id: ", session.id, | ||
"\n type: ", session.config.type, | ||
"\n started, but not initialized. ", | ||
"Either the adapter definition or the used configuration is wrong, ", | ||
"or the defined adapter doesn't speak DAP", | ||
})) | ||
end | ||
end | ||
end | ||
end | ||
|
||
|
||
return M |