commit dbe17da1206d9a19281aa2c3c851f864548b9586
parent 15248687110f9f8a46dd68c7bccf0a59ad6d1996
Author: v1nh1shungry <v1nh1shungry@outlook.com>
Date: Tue, 20 May 2025 10:44:26 +0800
fix(diagnostic): deprecate `float` in `vim.diagnostic.Opts.Jump` (#34037)
Diffstat:
3 files changed, 25 insertions(+), 9 deletions(-)
diff --git a/runtime/doc/deprecated.txt b/runtime/doc/deprecated.txt
@@ -21,7 +21,8 @@ API
DIAGNOSTICS
-• "float" in |vim.diagnostic.JumpOpts|. Use "on_jump" instead.
+• "float" in |vim.diagnostic.JumpOpts|. Use "on_jump" instead.
+• "float" in |vim.diagnostic.Opts.Jump|. Use "on_jump" instead.
HIGHLIGHTS
diff --git a/runtime/doc/diagnostic.txt b/runtime/doc/diagnostic.txt
@@ -604,8 +604,8 @@ Lua module: vim.diagnostic *diagnostic-api*
*vim.diagnostic.Opts.Jump*
Fields: ~
- • {float}? (`boolean|vim.diagnostic.Opts.Float`, default: false)
- Default value of the {float} parameter of
+ • {on_jump}? (`fun(diagnostic:vim.Diagnostic?, bufnr:integer)`)
+ Default value of the {on_jump} parameter of
|vim.diagnostic.jump()|.
• {wrap}? (`boolean`, default: true) Default value of the {wrap}
parameter of |vim.diagnostic.jump()|.
diff --git a/runtime/lua/vim/diagnostic.lua b/runtime/lua/vim/diagnostic.lua
@@ -288,9 +288,8 @@ end
--- @class vim.diagnostic.Opts.Jump
---
---- Default value of the {float} parameter of |vim.diagnostic.jump()|.
---- (default: false)
---- @field float? boolean|vim.diagnostic.Opts.Float
+--- Default value of the {on_jump} parameter of |vim.diagnostic.jump()|.
+--- @field on_jump? fun(diagnostic:vim.Diagnostic?, bufnr:integer)
---
--- Default value of the {wrap} parameter of |vim.diagnostic.jump()|.
--- (default: true)
@@ -346,9 +345,6 @@ local global_diagnostic_options = {
update_in_insert = false,
severity_sort = false,
jump = {
- -- Do not show floating window
- float = false,
-
-- Wrap around buffer
wrap = true,
},
@@ -1158,6 +1154,25 @@ function M.config(opts, namespace)
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