Home Explore Blog CI



neovim

15th chunk of `runtime/doc/diagnostic.txt`
a428264e79a436717f8b15d58e9e173f03727f3ac1b132a60000000100000961
 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|.

setloclist({opts})                               *vim.diagnostic.setloclist()*
    Add buffer diagnostics to the location list.

    Parameters: ~
      • {opts}  (`table?`) Configuration table with the following keys:
                • {namespace}? (`integer[]|integer`) Only add diagnostics from
                  the given namespace(s).
                • {winnr}? (`integer`, default: `0`) Window number to set
                  location list for.
                • {open}? (`boolean`, default: `true`) Open the location list
                  after setting.
                • {title}? (`string`) Title of the location list. Defaults to
                  "Diagnostics".
                • {severity}? (`vim.diagnostic.SeverityFilter`) See
                  |diagnostic-severity|.
                • {format}? (`fun(diagnostic:vim.Diagnostic): string?`) A
                  function that takes a diagnostic as input and returns a
                  string or nil. If the return value is nil, the diagnostic is
                  not displayed in the location list. Else the output text is
                  used to display the diagnostic.

setqflist({opts})                                 *vim.diagnostic.setqflist()*
    Add all diagnostics to the quickfix list.

    Parameters: ~
      • {opts}  (`table?`) Configuration table with the following keys:
         

Title: Diagnostic Functions: Setting Diagnostics and Populating Location/Quickfix Lists
Summary
This section details how to set diagnostics and populate the location and quickfix lists in Neovim. `vim.diagnostic.set()` sets diagnostics for a given namespace and buffer. `vim.diagnostic.setloclist()` adds buffer diagnostics to the location list, allowing filtering by namespace, severity, and custom formatting. `vim.diagnostic.setqflist()` adds all diagnostics to the quickfix list, also with configuration options.