diff --git a/lua/godotdev/health.lua b/lua/godotdev/health.lua index a59b0a1..2fcfd76 100644 --- a/lua/godotdev/health.lua +++ b/lua/godotdev/health.lua @@ -1,29 +1,37 @@ local health = vim.health local M = {} --- default port M.opts = { editor_port = 6005 } function M.setup(opts) M.opts = vim.tbl_extend("force", M.opts, opts or {}) end -local function port_open(host, port) - local cmd - if vim.fn.executable("ncat") == 1 then - cmd = string.format("ncat -z -w 1 %s %d 2>/dev/null", host, port) - else - return false - end - vim.fn.system(cmd) - return vim.v.shell_error == 0 -end - local is_windows = vim.loop.os_uname().sysname == "Windows_NT" +local function port_open(host, port) + if is_windows then + if vim.fn.executable("ncat") ~= 1 then + return false + end + local cmd = string.format("ncat -z -w 1 %s %d 2>/dev/null", host, port) + vim.fn.system(cmd) + return vim.v.shell_error == 0 + else + -- On macOS/Linux, attempt nc if available; otherwise assume reachable + if vim.fn.executable("nc") == 1 then + local cmd = string.format("nc -z -w 1 %s %d 2>/dev/null", host, port) + vim.fn.system(cmd) + return vim.v.shell_error == 0 + end + return true + end +end + function M.check() health.start("Godotdev.nvim") + -- only check ncat on Windows if is_windows then if vim.fn.executable("ncat") == 1 then health.ok("'ncat' is installed") @@ -34,8 +42,9 @@ function M.check() end end + -- Godot editor LSP port check local port = M.opts.editor_port - if port_open("127.0.0.1", port) or not is_windows then + if port_open("127.0.0.1", port) then health.ok("Godot editor LSP detected on port " .. port) else local msg = string.format(