From 93261ce209b487cdb8f85dea97027c4c2ed3f7a3 Mon Sep 17 00:00:00 2001 From: smnatale Date: Mon, 13 Apr 2026 11:25:23 +0100 Subject: [PATCH 1/3] implement checkhealth status messages --- lua/coderabbit/health.lua | 60 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 lua/coderabbit/health.lua diff --git a/lua/coderabbit/health.lua b/lua/coderabbit/health.lua new file mode 100644 index 0000000..39e1c59 --- /dev/null +++ b/lua/coderabbit/health.lua @@ -0,0 +1,60 @@ +local M = {} + +function M.check() + vim.health.start("coderabbit.nvim") + + -- Neovim version + if vim.fn.has("nvim-0.10") == 1 then + vim.health.ok("Neovim >= 0.10") + else + vim.health.error("Neovim >= 0.10 required") + end + + -- CLI binary + local config = require("coderabbit.config") + local cfg = config.get() + local binary = cfg.cli.binary + + if vim.fn.executable(binary) == 1 then + vim.health.ok("CLI found: " .. binary) + + -- CLI version + local version = vim.fn.system({ binary, "--version" }) + version = vim.trim(version) + if vim.v.shell_error == 0 and version ~= "" then + vim.health.ok("CLI version: " .. version) + else + vim.health.warn("Could not determine CLI version") + end + + -- Authentication + local auth_raw = vim.fn.system({ binary, "auth", "status", "--agent" }) + if vim.v.shell_error == 0 then + local ok, auth = pcall(vim.json.decode, auth_raw) + if ok and auth.authenticated then + local user = auth.user and auth.user.username or "unknown" + local org = auth.currentOrg and auth.currentOrg.name or "none" + vim.health.ok("Authenticated as " .. user .. " (org: " .. org .. ")") + else + vim.health.warn("Not authenticated", { "Run: cr auth login" }) + end + else + vim.health.warn("Could not check auth status", { "Run: cr auth login" }) + end + else + vim.health.error("CLI not found: " .. binary, { + "Install with: curl -fsSL https://cli.coderabbit.ai/install.sh | sh", + }) + end + + -- Configuration + if config._current then + vim.health.ok("Plugin configured") + else + vim.health.warn("setup() has not been called yet", { + 'Add require("coderabbit").setup({}) to your config', + }) + end +end + +return M From 7eb7215925d6ef42daa104dbb46e93bf35da168d Mon Sep 17 00:00:00 2001 From: smnatale Date: Mon, 13 Apr 2026 11:34:25 +0100 Subject: [PATCH 2/3] @coderabbitai suggestions --- lua/coderabbit/health.lua | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/lua/coderabbit/health.lua b/lua/coderabbit/health.lua index 39e1c59..77160c7 100644 --- a/lua/coderabbit/health.lua +++ b/lua/coderabbit/health.lua @@ -10,8 +10,19 @@ function M.check() vim.health.error("Neovim >= 0.10 required") end - -- CLI binary + -- Configuration local config = require("coderabbit.config") + local configured = config._current ~= nil + + if configured then + vim.health.ok("Plugin configured") + else + vim.health.warn("setup() has not been called yet", { + 'Add require("coderabbit").setup({}) to your config', + }) + end + + -- CLI binary local cfg = config.get() local binary = cfg.cli.binary @@ -36,10 +47,10 @@ function M.check() local org = auth.currentOrg and auth.currentOrg.name or "none" vim.health.ok("Authenticated as " .. user .. " (org: " .. org .. ")") else - vim.health.warn("Not authenticated", { "Run: cr auth login" }) + vim.health.warn("Not authenticated", { "Run: " .. binary .. " auth login" }) end else - vim.health.warn("Could not check auth status", { "Run: cr auth login" }) + vim.health.warn("Could not check auth status", { "Run: " .. binary .. " auth login" }) end else vim.health.error("CLI not found: " .. binary, { @@ -47,14 +58,6 @@ function M.check() }) end - -- Configuration - if config._current then - vim.health.ok("Plugin configured") - else - vim.health.warn("setup() has not been called yet", { - 'Add require("coderabbit").setup({}) to your config', - }) - end end return M From affc792beb3908dba3f9ee2b26f1c88781b075a3 Mon Sep 17 00:00:00 2001 From: smnatale Date: Mon, 13 Apr 2026 11:35:28 +0100 Subject: [PATCH 3/3] stylua fix --- lua/coderabbit/health.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/lua/coderabbit/health.lua b/lua/coderabbit/health.lua index 77160c7..2c836d9 100644 --- a/lua/coderabbit/health.lua +++ b/lua/coderabbit/health.lua @@ -57,7 +57,6 @@ function M.check() "Install with: curl -fsSL https://cli.coderabbit.ai/install.sh | sh", }) end - end return M