Repository: neovim/neovim
File: runtime/lua/vim/diagnostic.lua (Lua)

Code before:
    end
    if type(suffix_opt) == 'function' then
      --- @cast suffix_opt fun(...): string?, string?
      local suffix0, suffix_hl_group0 = suffix_opt(diagnostic, i, #diagnostics)
      suffix, suffix_hl_group = suffix0 or '', suffix_hl_group0 or 'NormalFloat'
    end
    local hiname = floating_highlight_map[diagnostic.severity]
    local message_lines = vim.split(diagnostic.message, '\n')
    local default_pre = string.rep(' ', #prefix)
    for j = 1, #message_lines do
      local pre = j == 1 and prefix or default_pre
      local suf = j == #message_lines and suffix or ''
      lines[#lines + 1] = pre .. message_lines[j] .. suf
      highlights[#highlights + 1] = {
        hlname = hiname,
        prefix = {
          length = j == 1 and #prefix or 0,
          hlname = prefix_hl_group,
        },
        suffix = {
          length = #suf,
          hlname = suffix_hl_group,
        },
      }
    end

    local related_info = diagnostic._related_information or {}
    local n_related_info = #related_info

    -- Fold additional related info objects so they don't take up too much space.
    if n_related_info > 3 then
      local n_lines = #lines
      fold_ranges[#fold_ranges + 1] = { n_lines + 3, n_lines + n_related_info }
    end

    for _, info in ipairs(related_info) do
      -- TODO: Somehow allow users to open the location when their cursor is over it?
      local file_name = vim.fs.basename(vim.uri_to_fname(info.location.uri))
      local info_suffix = ': ' .. info.message
      lines[#lines + 1] = string.format(
        '%s%s:%s:%s%s',
        default_pre,
        file_name,
        info.location.range.start.line,
        info.location.range.start.character,
        info_suffix
      )
      highlights[#highlights + 1] = {
        hlname = '@string.special.path',
        prefix = {
          length = #default_pre,

Review comment (suggestion):
```suggestion
    -- [do something (what?) with] DiagnosticRelatedInformation.
    for _, info in ipairs(related_info) do
```

Code after:
    local hiname = floating_highlight_map[diagnostic.severity]
    local message_lines = vim.split(diagnostic.message, '\n')
    local default_pre = string.rep(' ', #prefix)
    for j = 1, #message_lines do
      local pre = j == 1 and prefix or default_pre
      local suf = j == #message_lines and suffix or ''
      lines[#lines + 1] = pre .. message_lines[j] .. suf
      highlights[#highlights + 1] = {
        hlname = hiname,
        prefix = {
          length = j == 1 and #prefix or 0,
          hlname = prefix_hl_group,
        },
        suffix = {
          length = #suf,
          hlname = suffix_hl_group,
        },
      }
    end

    ---@type lsp.DiagnosticRelatedInformation[]
    local related_info = vim.tbl_get(diagnostic, 'user_data', 'lsp', 'relatedInformation') or {}

    -- Below the diagnostic, show its LSP related information (if any) in the form of file name and
    -- range, plus description.
    for _, info in ipairs(related_info) do
      -- TODO: Somehow allow users to open the location when their cursor is over it?
      local file_name = vim.fs.basename(vim.uri_to_fname(info.location.uri))
      local info_suffix = ': ' .. info.message
      lines[#lines + 1] = string.format(
        '%s%s:%s:%s%s',
        default_pre,
        file_name,
        info.location.range.start.line,
        info.location.range.start.character,
        info_suffix
      )
      highlights[#highlights + 1] = {
        hlname = '@string.special.path',
        prefix = {
          length = #default_pre,
          hlname = prefix_hl_group,
        },
        suffix = {
          length = #info_suffix,
          hlname = 'NormalFloat',
        },
      }
    end
  end