Home Explore Blog CI



neovim

14th chunk of `runtime/doc/diagnostic.txt`
e0e1f951c21acd10540154d549df954adf5b6cd549a21dac0000000100000ede

is_enabled({filter})                             *vim.diagnostic.is_enabled()*
    Check whether diagnostics are enabled.

    Attributes: ~
        Since: 0.10.0

    Parameters: ~
      • {filter}  (`table?`) Optional filters |kwargs|, or `nil` for all.
                  • {ns_id}? (`integer`) Diagnostic namespace, or `nil` for
                    all.
                  • {bufnr}? (`integer`) Buffer number, or 0 for current
                    buffer, or `nil` for all buffers.

    Return: ~
        (`boolean`)

jump({opts})                                           *vim.diagnostic.jump()*
    Move to a diagnostic.

    Parameters: ~
      • {opts}  (`vim.diagnostic.JumpOpts`) See |vim.diagnostic.JumpOpts|.

    Return: ~
        (`vim.Diagnostic?`) The diagnostic that was moved to. See
        |vim.Diagnostic|.

                                                      *vim.diagnostic.match()*
match({str}, {pat}, {groups}, {severity_map}, {defaults})
    Parse a diagnostic from a string.

    For example, consider a line of output from a linter: >
        WARNING filename:27:3: Variable 'foo' does not exist
<

    This can be parsed into |vim.Diagnostic| structure with: >lua
        local s = "WARNING filename:27:3: Variable 'foo' does not exist"
        local pattern = "^(%w+) %w+:(%d+):(%d+): (.+)$"
        local groups = { "severity", "lnum", "col", "message" }
        vim.diagnostic.match(s, pattern, groups, { WARNING = vim.diagnostic.WARN })
<

    Parameters: ~
      • {str}           (`string`) String to parse diagnostics from.
      • {pat}           (`string`) Lua pattern with capture groups.
      • {groups}        (`string[]`) List of fields in a |vim.Diagnostic|
                        structure to associate with captures from {pat}.
      • {severity_map}  (`table`) A table mapping the severity field from
                        {groups} with an item from |vim.diagnostic.severity|.
      • {defaults}      (`table?`) Table of default values for any fields not
                        listed in {groups}. When omitted, numeric values
                        default to 0 and "severity" defaults to ERROR.

    Return: ~
        (`vim.Diagnostic?`) |vim.Diagnostic| structure or `nil` if {pat} fails
        to match {str}.

open_float({opts})                               *vim.diagnostic.open_float()*
    Show diagnostics in a floating window.

    Parameters: ~
      • {opts}  (`vim.diagnostic.Opts.Float?`) See
                |vim.diagnostic.Opts.Float|.

    Return (multiple): ~
        (`integer?`) float_bufnr
        (`integer?`) winid

reset({namespace}, {bufnr})                           *vim.diagnostic.reset()*
    Remove all diagnostics from the given namespace.

    Unlike |vim.diagnostic.hide()|, this function removes all saved
    diagnostics. They cannot be redisplayed using |vim.diagnostic.show()|. To
    simply remove diagnostic decorations in a way that they can be
    re-displayed, use |vim.diagnostic.hide()|.

    Parameters: ~
      • {namespace}  (`integer?`) Diagnostic namespace. When omitted, remove
                     diagnostics from all namespaces.
      • {bufnr}      (`integer?`) Remove diagnostics for the given buffer.
                     When omitted, diagnostics are removed for all buffers.

set({namespace}, {bufnr}, {diagnostics}, {opts})        *vim.diagnostic.set()*
    Set diagnostics for the given namespace and buffer.

    Parameters: ~
      • {namespace}    (`integer`) The diagnostic namespace
      • {bufnr}        (`integer`) Buffer number
      • {diagnostics}  (`vim.Diagnostic.Set[]`) See |vim.Diagnostic.Set|.
      • {opts}         (`vim.diagnostic.Opts?`) Display options to pass to
                       |vim.diagnostic.show()|. See |vim.diagnostic.Opts|.

Title: Diagnostic Functions: Matching, Displaying, Resetting, and Setting Diagnostics
Summary
This section outlines functions for managing diagnostics: `vim.diagnostic.is_enabled()` checks if diagnostics are enabled, `vim.diagnostic.jump()` moves to a diagnostic, `vim.diagnostic.match()` parses diagnostics from a string using a Lua pattern, `vim.diagnostic.open_float()` displays diagnostics in a floating window, `vim.diagnostic.reset()` removes diagnostics, and `vim.diagnostic.set()` sets diagnostics for a given namespace and buffer.