Remove redundant checks

This commit is contained in:
mathijs-bakker
2025-08-20 17:47:18 +02:00
parent 7f86fec601
commit e7693924b6

View File

@@ -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(