Add dependencies check
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
local health = vim.health
|
||||
local M = {}
|
||||
|
||||
M.opts = { editor_port = 6005 }
|
||||
M.opts = {
|
||||
editor_port = 6005,
|
||||
debug_port = 6006,
|
||||
}
|
||||
|
||||
function M.setup(opts)
|
||||
M.opts = vim.tbl_extend("force", M.opts, opts or {})
|
||||
@@ -10,53 +13,86 @@ end
|
||||
local is_windows = vim.loop.os_uname().sysname == "Windows_NT"
|
||||
|
||||
local function port_open(host, port)
|
||||
local cmd
|
||||
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
|
||||
cmd = string.format("ncat -z -w 1 %s %d 2>NUL", host, port)
|
||||
else
|
||||
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
|
||||
if vim.fn.executable("nc") ~= 1 then
|
||||
return true -- assume port ok if nc is missing
|
||||
end
|
||||
return true
|
||||
cmd = string.format("nc -z -w 1 %s %d >/dev/null 2>&1", host, port)
|
||||
end
|
||||
vim.fn.system(cmd)
|
||||
return vim.v.shell_error == 0
|
||||
end
|
||||
|
||||
-- Check if a plugin is installed, works with Lazy.nvim
|
||||
local function plugin_installed(name)
|
||||
if name == "nvim-lspconfig" then
|
||||
return vim.fn.exists(":LspInfo") == 2
|
||||
elseif name == "nvim-dap" then
|
||||
return vim.fn.exists(":DapContinue") == 2
|
||||
elseif name == "nvim-treesitter" then
|
||||
return pcall(require, "nvim-treesitter.configs")
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function M.check()
|
||||
health.start("Godotdev.nvim")
|
||||
|
||||
if is_windows then
|
||||
if vim.fn.executable("ncat") == 1 then
|
||||
health.ok("'ncat' is installed")
|
||||
-- plugin dependencies
|
||||
for _, plugin in ipairs({ "nvim-lspconfig", "nvim-treesitter", "nvim-dap" }) do
|
||||
if plugin_installed(plugin) then
|
||||
health.ok("Dependency '" .. plugin .. "' is installed")
|
||||
else
|
||||
health.error([[Windows: 'ncat' not found. Install via Scoop or Chocolatey:
|
||||
scoop install nmap
|
||||
choco install nmap]])
|
||||
health.warn("Dependency '" .. plugin .. "' not found. Some features may not work.")
|
||||
end
|
||||
end
|
||||
|
||||
local port = M.opts.editor_port
|
||||
if port_open("127.0.0.1", port) then
|
||||
health.ok("Godot editor LSP detected on port " .. port)
|
||||
-- Godot editor LSP
|
||||
local editor_port = M.opts.editor_port
|
||||
if port_open("127.0.0.1", editor_port) then
|
||||
health.ok("Godot editor LSP detected on port " .. editor_port)
|
||||
else
|
||||
local msg = string.format(
|
||||
health.warn(string.format(
|
||||
[[
|
||||
Godot editor LSP not detected on port %d.
|
||||
Make sure the Godot editor is running with the LSP server enabled on this port.
|
||||
Make sure the Godot editor is running with LSP server enabled.
|
||||
|
||||
- Open your project in Godot.
|
||||
- Enable the LSP server (Editor Settings → Network → Enable TCP LSP server).
|
||||
- Confirm the port matches %d (change `editor_port` in your config if needed).
|
||||
]],
|
||||
port,
|
||||
port
|
||||
)
|
||||
health.warn(msg)
|
||||
editor_port,
|
||||
editor_port
|
||||
))
|
||||
end
|
||||
|
||||
-- Godot editor debug server
|
||||
local debug_port = M.opts.debug_port
|
||||
if plugin_installed("nvim-dap") then
|
||||
if port_open("127.0.0.1", debug_port) then
|
||||
health.ok("Godot editor debug server detected on port " .. debug_port)
|
||||
else
|
||||
health.warn("Godot editor debug server not detected on port " .. debug_port)
|
||||
end
|
||||
end
|
||||
|
||||
-- Windows: ncat check
|
||||
if is_windows then
|
||||
if vim.fn.executable("ncat") == 1 then
|
||||
health.ok("'ncat' is installed")
|
||||
else
|
||||
health.error([[
|
||||
Windows: 'ncat' not found. Install via Scoop or Chocolatey:
|
||||
scoop install nmap
|
||||
choco install nmap
|
||||
]])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user