Skip to content

Hook Results

Federico Conticello edited this page Mar 24, 2026 · 1 revision

Hook Results

Any hook can return a table with one or more of these fields. All fields are optional.

Content Modification

modified_content

Only meaningful in on_document_save. Returns modified text to be saved instead of the original.

return { modified_content = cleaned_text }

Notifications

status_message

Shows a toast notification in the editor.

return {
    status_message = {
        level = "info",    -- "info", "warning", "error"
        text = "Lint passed: 0 issues"
    }
}

Diagnostics

diagnostics

Array of diagnostic objects. Typically returned from on_document_lint.

return {
    diagnostics = {
        {
            line = 10,
            message = "Unused variable 'x'",
            level = "warning",
            column = 5,
            fix_message = "Remove or use the variable",
            url = "https://example.com/rules/unused-var"
        }
    }
}

Line Annotations

line_annotations

Array of line annotation objects. Typically returned from on_highlight_request.

return {
    line_annotations = {
        { line = 5, text = "!", color = {255, 0, 0} },
        { line = 12, text = "?", color = {255, 255, 0} }
    }
}

Widgets

split_view, tree_view, terminal_view

Display a widget panel. See Widget API for full documentation.

Navigation

open_file

Opens a file in the editor as a new tab.

return { open_file = "/path/to/file.rs" }

goto_line

Jumps to a specific line in the current document (1-indexed).

return { goto_line = 42 }

Clipboard

clipboard_text

Copies text to the system clipboard.

return { clipboard_text = "copied content" }

Combining Results

You can return multiple fields at once:

return {
    diagnostics = parsed_diagnostics,
    status_message = {
        level = "info",
        text = #parsed_diagnostics .. " issues found"
    },
    tree_view = {
        title = "Lint Results",
        root = results_tree
    }
}

Clone this wiki locally