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

Code before:
--- then virtual text will not be enabled for those diagnostics.
---
---@param opts vim.diagnostic.Opts? When omitted or `nil`, retrieve the current
---       configuration. Otherwise, a configuration table (see |vim.diagnostic.Opts|).
---@param namespace integer? Update the options for the given namespace.
---                          When omitted, update the global diagnostic options.
---@return vim.diagnostic.Opts? : Current diagnostic config if {opts} is omitted.
function M.config(opts, namespace)
  vim.validate('opts', opts, 'table', true)
  vim.validate('namespace', namespace, 'number', true)

  local t --- @type vim.diagnostic.Opts
  if namespace then
    local ns = M.get_namespace(namespace)
    t = ns.opts
  else
    t = global_diagnostic_options
  end

  if not opts then
    -- Return current config
    return vim.deepcopy(t, true)
  end

  if opts.jump and opts.jump.float ~= nil then ---@diagnostic disable-line
    vim.deprecate('opts.jump.float', 'opts.jump.on_jump', '0.14')
  end

  for k, v in
    pairs(opts --[[@as table<any,any>]])
  do
    t[k] = v
  end

  if namespace then
    for bufnr, v in pairs(diagnostic_cache) do
      if v[namespace] then
        M.show(namespace, bufnr)
      end
    end
  else
    for bufnr, v in pairs(diagnostic_cache) do
      for ns in pairs(v) do
        M.show(ns, bufnr)
      end
    end
  end
end

--- Set diagnostics for the given namespace and buffer.
---

Review comment (suggestion):
Until we remove the field entirely we still want to apply the `float` option. You should do something similar to what I did in https://github.com/neovim/neovim/pull/33850 and use `opts.on_jump` to call `open_float`.

Code after:
--- then virtual text will not be enabled for those diagnostics.
---
---@param opts vim.diagnostic.Opts? When omitted or `nil`, retrieve the current
---       configuration. Otherwise, a configuration table (see |vim.diagnostic.Opts|).
---@param namespace integer? Update the options for the given namespace.
---                          When omitted, update the global diagnostic options.
---@return vim.diagnostic.Opts? : Current diagnostic config if {opts} is omitted.
function M.config(opts, namespace)
  vim.validate('opts', opts, 'table', true)
  vim.validate('namespace', namespace, 'number', true)

  local t --- @type vim.diagnostic.Opts
  if namespace then
    local ns = M.get_namespace(namespace)
    t = ns.opts
  else
    t = global_diagnostic_options
  end

  if not opts then
    -- Return current config
    return vim.deepcopy(t, true)
  end

  if opts.jump and opts.jump.float ~= nil then ---@diagnostic disable-line
    vim.deprecate('opts.jump.float', 'opts.jump.on_jump', '0.14')

    local float_opts = opts.jump.float ---@type table|boolean
    if float_opts then
      float_opts = type(float_opts) == 'table' and float_opts or {}

      opts.jump.on_jump = function(_, bufnr)
        M.open_float(vim.tbl_extend('keep', float_opts, {
          bufnr = bufnr,
          scope = 'cursor',
          focus = false,
        }))
      end
    end

    opts.jump.float = nil ---@diagnostic disable-line
  end

  for k, v in
    pairs(opts --[[@as table<any,any>]])
  do
    t[k] = v
  end

  if namespace then
    for bufnr, v in pairs(diagnostic_cache) do