Home Explore Blog CI



neovim

13th chunk of `runtime/doc/diagnostic.txt`
b83d70549bfc17ea7687cac9628f0348b3c7b7b43615cab70000000100000fc1
 Diagnostic namespace, or `nil` for
                    all.
                  • {bufnr}? (`integer`) Buffer number, or 0 for current
                    buffer, or `nil` for all buffers.

fromqflist({list})                               *vim.diagnostic.fromqflist()*
    Convert a list of quickfix items to a list of diagnostics.

    Parameters: ~
      • {list}  (`table[]`) List of quickfix items from |getqflist()| or
                |getloclist()|.

    Return: ~
        (`vim.Diagnostic[]`) See |vim.Diagnostic|.

get({bufnr}, {opts})                                    *vim.diagnostic.get()*
    Get current diagnostics.

    Modifying diagnostics in the returned table has no effect. To set
    diagnostics in a buffer, use |vim.diagnostic.set()|.

    Parameters: ~
      • {bufnr}  (`integer?`) Buffer number to get diagnostics from. Use 0 for
                 current buffer or nil for all buffers.
      • {opts}   (`vim.diagnostic.GetOpts?`) See |vim.diagnostic.GetOpts|.

    Return: ~
        (`vim.Diagnostic[]`) Fields `bufnr`, `end_lnum`, `end_col`, and
        `severity` are guaranteed to be present. See |vim.Diagnostic|.

get_namespace({namespace})                    *vim.diagnostic.get_namespace()*
    Get namespace metadata.

    Parameters: ~
      • {namespace}  (`integer`) Diagnostic namespace

    Return: ~
        (`vim.diagnostic.NS`) Namespace metadata. See |vim.diagnostic.NS|.

get_namespaces()                             *vim.diagnostic.get_namespaces()*
    Get current diagnostic namespaces.

    Return: ~
        (`table<integer,vim.diagnostic.NS>`) List of active diagnostic
        namespaces |vim.diagnostic|.

get_next({opts})                                   *vim.diagnostic.get_next()*
    Get the next diagnostic closest to the cursor position.

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

    Return: ~
        (`vim.Diagnostic?`) Next diagnostic. See |vim.Diagnostic|.

get_prev({opts})                                   *vim.diagnostic.get_prev()*
    Get the previous diagnostic closest to the cursor position.

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

    Return: ~
        (`vim.Diagnostic?`) Previous diagnostic. See |vim.Diagnostic|.

hide({namespace}, {bufnr})                             *vim.diagnostic.hide()*
    Hide currently displayed diagnostics.

    This only clears the decorations displayed in the buffer. Diagnostics can
    be redisplayed with |vim.diagnostic.show()|. To completely remove
    diagnostics, use |vim.diagnostic.reset()|.

    To hide diagnostics and prevent them from re-displaying, use
    |vim.diagnostic.enable()|.

    Parameters: ~
      • {namespace}  (`integer?`) Diagnostic namespace. When omitted, hide
                     diagnostics from all namespaces.
      • {bufnr}      (`integer?`) Buffer number, or 0 for current buffer. When
                     omitted, hide diagnostics in all buffers.

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.

Title: Diagnostic Functions: Retrieving Diagnostics, Namespaces, and Navigation
Summary
This section details functions for retrieving diagnostic data: `vim.diagnostic.get()` retrieves diagnostics in a buffer, `vim.diagnostic.get_namespace()` and `vim.diagnostic.get_namespaces()` retrieve namespace metadata, and `vim.diagnostic.get_next()` and `vim.diagnostic.get_prev()` navigate between diagnostics. It also covers functions to `hide` diagnostics, check if diagnostics `is_enabled`, and `jump` to a specific diagnostic. Finally, `match` is introduced as a function to parse a diagnostic from a string.