Skip to content

Commit 175f231

Browse files
authored
feat: show all backend install status in :CodePreviewStatus (#38)
1 parent 561660d commit 175f231

1 file changed

Lines changed: 28 additions & 13 deletions

File tree

lua/code-preview/init.lua

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -185,19 +185,6 @@ function M.status()
185185
table.insert(lines, "Neovim socket : not found")
186186
end
187187

188-
-- Hooks installed?
189-
local settings_path = vim.fn.getcwd() .. "/.claude/settings.local.json"
190-
local hooks_ok = false
191-
local f = io.open(settings_path, "r")
192-
if f then
193-
local content = f:read("*a")
194-
f:close()
195-
-- Detect both new and legacy hook markers
196-
hooks_ok = content:find("code-preview", 1, true) ~= nil
197-
or content:find("claude-preview", 1, true) ~= nil
198-
end
199-
table.insert(lines, "Hooks : " .. (hooks_ok and "installed" or "not installed"))
200-
201188
-- jq dependency
202189
local jq_ok = vim.fn.executable("jq") == 1
203190
table.insert(lines, "jq : " .. (jq_ok and "found" or "MISSING"))
@@ -206,6 +193,34 @@ function M.status()
206193
local diff = require("code-preview.diff")
207194
table.insert(lines, "Diff tab : " .. (diff.is_open() and "open" or "closed"))
208195

196+
-- Backends
197+
table.insert(lines, "")
198+
table.insert(lines, "Backends:")
199+
200+
-- Claude Code
201+
local claude_ok = false
202+
local settings_path = vim.fn.getcwd() .. "/.claude/settings.local.json"
203+
local f = io.open(settings_path, "r")
204+
if f then
205+
local content = f:read("*a")
206+
f:close()
207+
claude_ok = content:find("code-preview", 1, true) ~= nil
208+
or content:find("claude-preview", 1, true) ~= nil
209+
end
210+
if claude_ok then
211+
table.insert(lines, " Claude Code : installed")
212+
else
213+
table.insert(lines, " Claude Code : not installed -> :CodePreviewInstallClaudeCodeHooks")
214+
end
215+
216+
-- OpenCode
217+
local opencode_ok = vim.fn.filereadable(vim.fn.getcwd() .. "/.opencode/plugins/index.ts") == 1
218+
if opencode_ok then
219+
table.insert(lines, " OpenCode : installed")
220+
else
221+
table.insert(lines, " OpenCode : not installed -> :CodePreviewInstallOpenCodeHooks")
222+
end
223+
209224
vim.notify(table.concat(lines, "\n"), vim.log.levels.INFO, { title = "code-preview" })
210225
end
211226

0 commit comments

Comments
 (0)