Skip to content

Commit e6a8964

Browse files
chore(doc): auto generate docs
1 parent e59c826 commit e6a8964

1 file changed

Lines changed: 38 additions & 1 deletion

File tree

doc/guard.nvim.txt

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*guard.nvim.txt* For NVIM v0.8.0 Last change: 2026 January 18
1+
*guard.nvim.txt* For NVIM v0.8.0 Last change: 2026 January 31
22

33
==============================================================================
44
Table of Contents *guard.nvim-table-of-contents*
@@ -637,6 +637,43 @@ That’s what the attributes field does, it extracts them from the json table:
637637
Et voilà!
638638

639639

640+
SIGNATURES FOR CUSTOM LINTER FUNCTIONS ~
641+
642+
When writing custom lint logic, `fn` and `parse` receive buffer context:
643+
644+
>lua
645+
lint.fn(prev_lines, fname, cwd)
646+
lint.parse(result, bufnr, fname, cwd)
647+
<
648+
649+
**Parameters:**
650+
651+
- `prev_lines` — buffer content (string)
652+
- `result` — linter output (string)
653+
- `bufnr` — target buffer number
654+
- `fname` — absolute file path
655+
- `cwd` — working directory
656+
657+
Use `fname` and `cwd` when linters output relative paths (e.g., `terraform
658+
validate` on a directory returns diagnostics for all files).
659+
660+
**Example** — filtering `terraform validate` by current file:
661+
662+
>lua
663+
parse = function(result, bufnr, fname, cwd)
664+
local current = fname:sub(#cwd + 2) -- +2 to include '/'
665+
local decoded = vim.json.decode(result)
666+
667+
for _, d in ipairs(decoded.diagnostics or {}) do
668+
-- terraform returns relative filenames; match against current
669+
if d.range and d.range.filename == current then
670+
-- add to diagnostics...
671+
end
672+
end
673+
end
674+
<
675+
676+
640677
TAKE ADVANTAGE OF AUTOCMD EVENTS*guard.nvim-advanced-tips-take-advantage-of-autocmd-events*
641678

642679
Guard exposes a `GuardFmt` user event that you can use. It is called both

0 commit comments

Comments
 (0)