Skip to content

Commit 9356782

Browse files
committed
fix(health): error when lsof or pgrep are missing and port isn't set
closes #111
1 parent e235528 commit 9356782

2 files changed

Lines changed: 9 additions & 12 deletions

File tree

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@ Integrate the [opencode](https://github.com/sst/opencode) AI assistant with Neov
2020

2121
## 📦 Setup
2222

23-
> [!TIP]
24-
> Run `:checkhealth opencode` after setup.
25-
2623
### [lazy.nvim](https://github.com/folke/lazy.nvim)
2724

2825
```lua
@@ -71,6 +68,9 @@ programs.nixvim = {
7168
};
7269
```
7370

71+
> [!TIP]
72+
> Run `:checkhealth opencode` after setup.
73+
7474
## ⚙️ Configuration
7575

7676
`opencode.nvim` provides a rich and reliable default experience — see all available options and their defaults [here](./lua/opencode/config.lua).

lua/opencode/health.lua

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -79,23 +79,20 @@ function M.check()
7979
})
8080
end
8181

82-
if vim.fn.has("win32") == 0 then
82+
-- Binaries for auto-finding `opencode` process (Unix only)
83+
if vim.fn.has("win32") == 0 and not vim.g.opencode_opts.port then
8384
if vim.fn.executable("pgrep") == 1 then
84-
vim.health.ok(
85-
"`pgrep` available: it will be used to auto-find `opencode` if `vim.g.opencode_opts.port` is not set."
86-
)
85+
vim.health.ok("`pgrep` available.")
8786
else
88-
vim.health.warn(
87+
vim.health.error(
8988
"`pgrep` executable not found in `$PATH`.",
9089
{ "Install `pgrep` and ensure it's in your `$PATH`", "Or set `vim.g.opencode_opts.port`." }
9190
)
9291
end
9392
if vim.fn.executable("lsof") == 1 then
94-
vim.health.ok(
95-
"`lsof` available: it will be used to auto-find `opencode` if `vim.g.opencode_opts.port` is not set."
96-
)
93+
vim.health.ok("`lsof` available.")
9794
else
98-
vim.health.warn(
95+
vim.health.error(
9996
"`lsof` executable not found in `$PATH`.",
10097
{ "Install `lsof` and ensure it's in your `$PATH`", "Or set `vim.g.opencode_opts.port`." }
10198
)

0 commit comments

Comments
 (0)