Skip to content

Commit 56e9ac4

Browse files
committed
add health check via :checkhealth defold
1 parent 1db700f commit 56e9ac4

2 files changed

Lines changed: 69 additions & 0 deletions

File tree

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,11 @@ Here's how you can interact with Defold directly from Neovim:
266266
* **:SetupDefold**
267267
This commands does the required setup for Defold to use Neovim as its external editor (this will be done by default unless disabled, see config above)
268268

269+
## Troubleshooting
270+
271+
Should you have problems, please open Neovim (preferably through Defold) and use the command `:checkhealth defold`, this should give you a short list of several checks that might help to identify
272+
the issue. If it didn't, please be sure to include the health check if you report the issue.
273+
269274
## Special Thanks
270275

271276
- [astrochili/defold-annotations](https://github.com/astrochili/defold-annotations)

lua/defold/health.lua

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
local M = {}
2+
3+
function M.check()
4+
vim.health.start "System"
5+
6+
local os = require "defold.service.os"
7+
8+
vim.health.info(string.format("OS: %s / %s", os.name(), os.architecture()))
9+
10+
vim.health.start "Sidecar"
11+
12+
local sidecar_ok, sidecar = pcall(require, "defold.sidecar")
13+
if sidecar_ok then
14+
vim.health.ok(string.format("Sidecar Loaded Version: %s", sidecar.version))
15+
else
16+
vim.health.error(string.format("Sidecar Not Available: %s", sidecar))
17+
end
18+
19+
vim.health.start "Bridge"
20+
21+
local bridge_path_ok, bridge_path = pcall(sidecar.find_bridge_path, require("defold").plugin_root())
22+
if bridge_path_ok then
23+
vim.health.ok(string.format("Bridge Path: %s", bridge_path))
24+
else
25+
vim.health.error(string.format("Bridge Not Found: %s", bridge_path))
26+
end
27+
28+
vim.health.start "mobdap"
29+
30+
local debugger = require "defold.service.debugger"
31+
local mobdap_path = debugger.mobdap_path()
32+
33+
if mobdap_path ~= nil then
34+
vim.health.ok(string.format("mobdap Path: %s", mobdap_path))
35+
else
36+
vim.health.warn(string.format("mobdap not available: %s, debugger disabled", mobdap_path))
37+
end
38+
39+
vim.health.start "Defold"
40+
41+
local project = require "defold.project"
42+
43+
if project.is_defold_project() then
44+
vim.health.ok "Current project is Defold project"
45+
46+
local project_root = project.project_root(false)
47+
48+
if project_root then
49+
vim.health.ok(string.format("Project Root: %s", project_root))
50+
end
51+
else
52+
vim.health.warn "Current project is NOT a Defold project"
53+
end
54+
55+
local editor_port = project.editor_port()
56+
57+
if editor_port ~= nil then
58+
vim.health.ok(string.format("Editor Port found at: %d", editor_port))
59+
else
60+
vim.health.warn "Could not find editor port, is the editor running?"
61+
end
62+
end
63+
64+
return M

0 commit comments

Comments
 (0)