Skip to content

Commit b821192

Browse files
authored
fix: update deprecated method calls for diagnostic commands (#1563)
1 parent 562d972 commit b821192

3 files changed

Lines changed: 23 additions & 31 deletions

File tree

lua/lspsaga/diagnostic/init.lua

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -253,24 +253,26 @@ local FORWARD, BACKWARD = 1, -1
253253

254254
function diag:goto_pos(pos, opts)
255255
local is_forward = pos == FORWARD
256-
local entry = (is_forward and vim.diagnostic.get_next or vim.diagnostic.get_prev)(opts)
256+
local entry = vim.diagnostic.jump(vim.tbl_extend('keep', {
257+
count = is_forward and 1 or -1,
258+
on_jump = function()
259+
vim.diagnostic.open_float({
260+
border = config.ui.border,
261+
format = function(d)
262+
if not vim.bo[api.nvim_get_current_buf()].filetype == 'rust' then
263+
return d.message
264+
end
265+
return d.message:find('\\n`$') and d.message:gsub('\\n`$', '`') or d.message
266+
end,
267+
header = '',
268+
prefix = { '', 'Title' },
269+
})
270+
end,
271+
}, opts or {}))
272+
257273
if not entry then
258274
return
259275
end
260-
(is_forward and vim.diagnostic.goto_next or vim.diagnostic.goto_prev)(vim.tbl_extend('keep', {
261-
float = {
262-
border = config.ui.border,
263-
format = function(diagnostic)
264-
if not vim.bo[api.nvim_get_current_buf()].filetype == 'rust' then
265-
return diagnostic.message
266-
end
267-
return diagnostic.message:find('\n`$') and diagnostic.message:gsub('\n`$', '`')
268-
or diagnostic.message
269-
end,
270-
header = '',
271-
prefix = { '', 'Title' },
272-
},
273-
}, opts or {}))
274276
util.valid_markdown_parser()
275277
require('lspsaga.beacon').jump_beacon({ entry.lnum, entry.col }, #api.nvim_get_current_line())
276278
vim.schedule(function()

lua/lspsaga/util.lua

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,7 @@ function M.gen_truncate_line(width)
128128
end
129129

130130
function M.get_max_content_length(contents)
131-
vim.validate({
132-
contents = { contents, 't' },
133-
})
131+
vim.validate('contents', contents, 'table')
134132
local cells = {}
135133
for _, v in pairs(contents) do
136134
if v:find('\n.') then

lua/lspsaga/window.lua

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,10 @@ local ui = require('lspsaga').config.ui
44
local win = {}
55

66
local function make_floating_popup_options(opts)
7-
vim.validate({
8-
opts = { opts, 't', true },
9-
})
7+
vim.validate('opts', opts, 'table', true)
108
opts = opts or {}
11-
vim.validate({
12-
['opts.offset_x'] = { opts.offset_x, 'n', true },
13-
['opts.offset_y'] = { opts.offset_y, 'n', true },
14-
})
9+
vim.validate('opts.offset_x', opts.offset_x, 'number', true)
10+
vim.validate('opts.offset_y', opts.offset_y, 'number', true)
1511

1612
local anchor = ''
1713
local row, col
@@ -124,9 +120,7 @@ end
124120

125121
--float window only
126122
function obj:winsetconf(config)
127-
validate({
128-
config = { config, 't' },
129-
})
123+
validate('config', config, 'table')
130124
api.nvim_win_set_config(self.winid, config)
131125
return self
132126
end
@@ -144,9 +138,7 @@ function obj:setheight(height)
144138
end
145139

146140
function win:new_float(float_opt, enter, force)
147-
vim.validate({
148-
float_opt = { float_opt, 't', true },
149-
})
141+
vim.validate('float_opt', float_opt, 'table', true)
150142
enter = enter or false
151143

152144
self.bufnr = float_opt.bufnr or api.nvim_create_buf(false, false)

0 commit comments

Comments
 (0)