Home Explore Blog CI



neovim

11th chunk of `runtime/doc/diagnostic.txt`
b16cb20d9f970d7d82711f1d7a3ce5a7f39058741d4447990000000100000fc5
 severity
                         |diagnostic-severity|
      • {current_line}?  (`boolean`, default: `false`) Only show diagnostics
                         for the current line.
      • {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 by the handler. Else the
                         output text is used to display the diagnostic.

*vim.diagnostic.Opts.VirtualText*

    Fields: ~
      • {severity}?           (`vim.diagnostic.SeverityFilter`) Only show
                              virtual text for diagnostics matching the given
                              severity |diagnostic-severity|
      • {current_line}?       (`boolean`) Show or hide diagnostics based on
                              the current cursor line. If `true`, only
                              diagnostics on the current cursor line are
                              shown. If `false`, all diagnostics are shown
                              except on the current cursor line. If `nil`, all
                              diagnostics are shown. (default `nil`)
      • {source}?             (`boolean|"if_many"`) Include the diagnostic
                              source in virtual text. Use `'if_many'` to only
                              show sources if there is more than one
                              diagnostic source in the buffer. Otherwise, any
                              truthy value means to always show the diagnostic
                              source.
      • {spacing}?            (`integer`) Amount of empty spaces inserted at
                              the beginning of the virtual text.
      • {prefix}?             (`string|(fun(diagnostic:vim.Diagnostic,i:integer,total:integer): string)`)
                              Prepend diagnostic message with prefix. If a
                              `function`, {i} is the index of the diagnostic
                              being evaluated, and {total} is the total number
                              of diagnostics for the line. This can be used to
                              render diagnostic symbols or error codes.
      • {suffix}?             (`string|(fun(diagnostic:vim.Diagnostic): string)`)
                              Append diagnostic message with suffix. This can
                              be used to render an LSP diagnostic error code.
      • {format}?             (`fun(diagnostic:vim.Diagnostic): string?`) If
                              not nil, the return value is the text used to
                              display the diagnostic. Example: >lua
                                  function(diagnostic)
                                    if diagnostic.severity == vim.diagnostic.severity.ERROR then
                                      return string.format("E: %s", diagnostic.message)
                                    end
                                    return diagnostic.message
                                  end
<

                              If the return value is nil, the diagnostic is
                              not displayed by the handler.
      • {hl_mode}?            (`'replace'|'combine'|'blend'`) See
                              |nvim_buf_set_extmark()|.
      • {virt_text}?          (`[string,any][]`) See |nvim_buf_set_extmark()|.
      • {virt_text_pos}?      (`'eol'|'eol_right_align'|'inline'|'overlay'|'right_align'`)
                              See |nvim_buf_set_extmark()|.
      • {virt_text_win_col}?  (`integer`) See |nvim_buf_set_extmark()|.
      • {virt_text_hide}?     (`boolean`) See |nvim_buf_set_extmark()|.


config({opts}, {namespace})                          *vim.diagnostic.config()*
    Configure diagnostic options globally or for a specific diagnostic
    namespace.

    Configuration can be specified globally, per-namespace,

Title: Diagnostic Options Continued: Virtual Text Details and Configuration
Summary
This section expands on the `vim.diagnostic.Opts.VirtualText` options, detailing how to customize the display of diagnostics as virtual text. It covers options like filtering by severity and current line, including the diagnostic source, setting spacing, adding prefixes and suffixes, formatting the text, and controlling highlight modes and positions. It also introduces the `vim.diagnostic.config()` function for configuring diagnostic options globally or for specific namespaces.