Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CUSTOMIZE.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ A tool is specified as follows:
-- special
parse -- function: linter only, parses linter output to neovim diagnostic
events -- { name: string, opt: autocmd options }: override default events, for formatter autocmds only the first one is used (passed in from `:fmt`)
health -- function: called in health checks
}
```

Expand Down
3 changes: 2 additions & 1 deletion doc/guard.nvim.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
*guard.nvim.txt* For NVIM v0.8.0 Last change: 2025 May 16
*guard.nvim.txt* For NVIM v0.8.0 Last change: 2025 June 08

==============================================================================
Table of Contents *guard.nvim-table-of-contents*
Expand Down Expand Up @@ -194,6 +194,7 @@ A tool is specified as follows:
-- special
parse -- function: linter only, parses linter output to neovim diagnostic
events -- { name: string, opt: autocmd options }: override default events, for formatter autocmds only the first one is used (passed in from `:fmt`)
health -- function: called in health checks
}
<

Expand Down
34 changes: 19 additions & 15 deletions lua/guard/health.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,32 @@ local util = require('guard.util')
local events = require('guard.events')
local M = {}

local function check_cmd(conf, checked)
if conf.cmd and not vim.tbl_contains(checked, conf.cmd) then
if fn.executable(conf.cmd) == 1 then
ok(conf.cmd .. ' found')
else
error(conf.cmd .. ' not found')
end
table.insert(checked, conf.cmd)
end
end

local function executable_check()
local checked = {}
for _, item in pairs(filetype) do
for _, conf in ipairs(item.formatter or {}) do
if conf.cmd and not vim.tbl_contains(checked, conf.cmd) then
if fn.executable(conf.cmd) == 1 then
ok(conf.cmd .. ' found')
else
error(conf.cmd .. ' not found')
end
table.insert(checked, conf.cmd)
if conf.health then
conf.health()
else
check_cmd(conf, checked)
end
end

for _, conf in ipairs(item.linter or {}) do
if conf.cmd and not vim.tbl_contains(checked, conf.cmd) then
if fn.executable(conf.cmd) == 1 then
ok(conf.cmd .. ' found')
else
error(conf.cmd .. ' not found')
end
table.insert(checked, conf.cmd)
if conf.health then
conf.health()
else
check_cmd(conf, checked)
end
end
end
Expand Down
1 change: 1 addition & 0 deletions lua/guard/util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ function M.toolcopy(c)
env = c.env,
timeout = c.timeout,
parse = c.parse,
health = c.health,
}
end

Expand Down
Loading