From 7e54bc5b7ba6e771628498085d9f3af38c59aa2a Mon Sep 17 00:00:00 2001 From: James Weiland Date: Mon, 20 Apr 2026 15:33:52 -0500 Subject: [PATCH] fix: update deprecated method calls for diagnostic commands --- lua/lspsaga/diagnostic/init.lua | 32 +++++++++++++++++--------------- lua/lspsaga/util.lua | 4 +--- lua/lspsaga/window.lua | 18 +++++------------- 3 files changed, 23 insertions(+), 31 deletions(-) diff --git a/lua/lspsaga/diagnostic/init.lua b/lua/lspsaga/diagnostic/init.lua index a7fe8dd6a..de5ea5b56 100644 --- a/lua/lspsaga/diagnostic/init.lua +++ b/lua/lspsaga/diagnostic/init.lua @@ -253,24 +253,26 @@ local FORWARD, BACKWARD = 1, -1 function diag:goto_pos(pos, opts) local is_forward = pos == FORWARD - local entry = (is_forward and vim.diagnostic.get_next or vim.diagnostic.get_prev)(opts) + local entry = vim.diagnostic.jump(vim.tbl_extend('keep', { + count = is_forward and 1 or -1, + on_jump = function() + vim.diagnostic.open_float({ + border = config.ui.border, + format = function(d) + if not vim.bo[api.nvim_get_current_buf()].filetype == 'rust' then + return d.message + end + return d.message:find('\\n`$') and d.message:gsub('\\n`$', '`') or d.message + end, + header = '', + prefix = { '• ', 'Title' }, + }) + end, + }, opts or {})) + if not entry then return end - (is_forward and vim.diagnostic.goto_next or vim.diagnostic.goto_prev)(vim.tbl_extend('keep', { - float = { - border = config.ui.border, - format = function(diagnostic) - if not vim.bo[api.nvim_get_current_buf()].filetype == 'rust' then - return diagnostic.message - end - return diagnostic.message:find('\n`$') and diagnostic.message:gsub('\n`$', '`') - or diagnostic.message - end, - header = '', - prefix = { '• ', 'Title' }, - }, - }, opts or {})) util.valid_markdown_parser() require('lspsaga.beacon').jump_beacon({ entry.lnum, entry.col }, #api.nvim_get_current_line()) vim.schedule(function() diff --git a/lua/lspsaga/util.lua b/lua/lspsaga/util.lua index 648098622..c5c555dff 100644 --- a/lua/lspsaga/util.lua +++ b/lua/lspsaga/util.lua @@ -128,9 +128,7 @@ function M.gen_truncate_line(width) end function M.get_max_content_length(contents) - vim.validate({ - contents = { contents, 't' }, - }) + vim.validate('contents', contents, 'table') local cells = {} for _, v in pairs(contents) do if v:find('\n.') then diff --git a/lua/lspsaga/window.lua b/lua/lspsaga/window.lua index cd1543be2..9b2f670d3 100644 --- a/lua/lspsaga/window.lua +++ b/lua/lspsaga/window.lua @@ -4,14 +4,10 @@ local ui = require('lspsaga').config.ui local win = {} local function make_floating_popup_options(opts) - vim.validate({ - opts = { opts, 't', true }, - }) + vim.validate('opts', opts, 'table', true) opts = opts or {} - vim.validate({ - ['opts.offset_x'] = { opts.offset_x, 'n', true }, - ['opts.offset_y'] = { opts.offset_y, 'n', true }, - }) + vim.validate('opts.offset_x', opts.offset_x, 'number', true) + vim.validate('opts.offset_y', opts.offset_y, 'number', true) local anchor = '' local row, col @@ -124,9 +120,7 @@ end --float window only function obj:winsetconf(config) - validate({ - config = { config, 't' }, - }) + validate('config', config, 'table') api.nvim_win_set_config(self.winid, config) return self end @@ -144,9 +138,7 @@ function obj:setheight(height) end function win:new_float(float_opt, enter, force) - vim.validate({ - float_opt = { float_opt, 't', true }, - }) + vim.validate('float_opt', float_opt, 'table', true) enter = enter or false self.bufnr = float_opt.bufnr or api.nvim_create_buf(false, false)