Skip to content

Commit 0b40190

Browse files
committed
fix: compatibility with nvim-nightly
1 parent a187a13 commit 0b40190

15 files changed

+35
-7
lines changed

doc/rustaceanvim.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ rustaceanvim.dap.adapter.types.server *rustaceanvim.dap.adapter.types.server*
392392

393393

394394
*rustaceanvim.dap.client.Config*
395-
rustaceanvim.dap.client.Config : Configuration
395+
rustaceanvim.dap.client.Config : dap.Configuration
396396

397397
Fields: ~
398398
{type} (string) The dap adapter to use

ftplugin/rust.lua

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---@type rustaceanvim.Config
22
local config = require('rustaceanvim.config.internal')
3+
local compat = require('rustaceanvim.compat')
34

45
if not vim.g.loaded_rustaceanvim then
56
require('rustaceanvim.config.check').check_for_lspconfig_conflict(vim.schedule_wrap(function(warn)
@@ -22,7 +23,7 @@ if not vim.g.loaded_rustaceanvim then
2223
vim.lsp.commands['rust-analyzer.gotoLocation'] = function(command, ctx)
2324
local client = vim.lsp.get_client_by_id(ctx.client_id)
2425
if client then
25-
vim.lsp.util.jump_to_location(command.arguments[1], client.offset_encoding)
26+
compat.show_document(command.arguments[1], client.offset_encoding)
2627
end
2728
end
2829

@@ -37,6 +38,7 @@ if not vim.g.loaded_rustaceanvim then
3738
local cached_commands = require('rustaceanvim.cached_commands')
3839
cached_commands.set_last_debuggable(args)
3940
local rt_dap = require('rustaceanvim.dap')
41+
---@diagnostic disable-next-line: invisible
4042
rt_dap.start(args)
4143
end
4244

lua/rustaceanvim/cached_commands.lua

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ M.execute_last_debuggable = function(executableArgsOverride)
4343
args.executableArgs = executableArgsOverride
4444
end
4545
local rt_dap = require('rustaceanvim.dap')
46+
---@diagnostic disable-next-line: invisible
4647
rt_dap.start(args)
4748
else
4849
local debuggables = require('rustaceanvim.commands.debuggables')

lua/rustaceanvim/commands/code_action_group.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ local M = {}
1515
---@field arguments? any[]
1616

1717
---@param action rustaceanvim.RACodeAction | rustaceanvim.RACommand
18-
---@param client lsp.Client
18+
---@param client vim.lsp.Client
1919
---@param ctx table
2020
function M.apply_action(action, client, ctx)
2121
if action.edit then

lua/rustaceanvim/commands/debuggables.lua

+2
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ local function dap_run(args)
8686
local rt_dap = require('rustaceanvim.dap')
8787
local ok, dap = pcall(require, 'dap')
8888
if ok then
89+
---@diagnostic disable-next-line: invisible
8990
rt_dap.start(args, true, dap.run)
9091
local cached_commands = require('rustaceanvim.cached_commands')
9192
cached_commands.set_last_debuggable(args)
@@ -131,6 +132,7 @@ local function add_debuggables_to_nvim_dap(debuggables)
131132
if not debuggable then
132133
return
133134
end
135+
---@diagnostic disable-next-line: invisible
134136
rt_dap.start(debuggable.args, false, function(configuration)
135137
local name = 'Cargo: ' .. build_label(debuggable.args)
136138
if not _dap_configuration_added[name] then

lua/rustaceanvim/commands/open_cargo_toml.lua

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
local M = {}
22

3+
local compat = require('rustaceanvim.compat')
4+
35
local function get_params()
46
return {
57
textDocument = vim.lsp.util.make_text_document_params(0),
@@ -13,7 +15,7 @@ local function handler(_, result, ctx)
1315

1416
local client = vim.lsp.get_client_by_id(ctx.client_id)
1517
if client then
16-
vim.lsp.util.jump_to_location(result, client.offset_encoding)
18+
compat.show_document(result, client.offset_encoding)
1719
end
1820
end
1921

lua/rustaceanvim/commands/parent_module.lua

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
local M = {}
22

33
local rl = require('rustaceanvim.rust_analyzer')
4+
local compat = require('rustaceanvim.compat')
45

56
local function get_params()
67
return vim.lsp.util.make_position_params(0, nil)
@@ -20,7 +21,7 @@ local function handler(_, result, ctx)
2021

2122
local client = vim.lsp.get_client_by_id(ctx.client_id)
2223
if client then
23-
vim.lsp.util.jump_to_location(location, client.offset_encoding)
24+
compat.show_document(location, client.offset_encoding)
2425
end
2526
end
2627

lua/rustaceanvim/commands/rustc_unpretty.lua

+1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ local function get_vim_range(range, buf)
5151
-- Use the value of the last col of the previous row instead.
5252
erow = erow - 1
5353
if not buf or buf == 0 then
54+
---@diagnostic disable-next-line: assign-type-mismatch
5455
ecol = vim.fn.col { erow, '$' } - 1
5556
else
5657
ecol = #vim.api.nvim_buf_get_lines(buf, erow - 1, erow, false)[1]

lua/rustaceanvim/commands/ssr.lua

+3
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@ local M = {}
55
local function get_opts(query, visual_mode)
66
local opts = vim.lsp.util.make_position_params()
77
local range = (visual_mode and vim.lsp.util.make_given_range_params() or vim.lsp.util.make_range_params()).range
8+
---@diagnostic disable-next-line: inject-field
89
opts.query = query
10+
---@diagnostic disable-next-line: inject-field
911
opts.parseOnly = false
12+
---@diagnostic disable-next-line: inject-field
1013
opts.selections = { range }
1114
return opts
1215
end

lua/rustaceanvim/compat.lua

+13
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
---@diagnostic disable: deprecated, duplicate-doc-alias
2+
13
---@mod rustaceanvim.compat compativility layer for
24
---API calls that are deprecated or removed in nvim nightly
35

@@ -15,4 +17,15 @@ function compat.get_line_diagnostics()
1517
return vim.lsp.diagnostic.get_line_diagnostics()
1618
end
1719

20+
---@param location lsp.Location|lsp.LocationLink
21+
---@param offset_encoding 'utf-8'|'utf-16'|'utf-32'?
22+
---@return boolean `true` if the jump succeeded
23+
function compat.show_document(location, offset_encoding)
24+
local show_document = vim.lsp.show_document
25+
if not show_document then
26+
vim.lsp.util.jump_to_location(location, offset_encoding)
27+
end
28+
return show_document(location, offset_encoding, { focus = true })
29+
end
30+
1831
return compat

lua/rustaceanvim/config/init.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ vim.g.rustaceanvim = vim.g.rustaceanvim
253253
---@alias rustaceanvim.dap.adapter.types.executable "executable"
254254
---@alias rustaceanvim.dap.adapter.types.server "server"
255255

256-
---@class rustaceanvim.dap.client.Config: Configuration
256+
---@class rustaceanvim.dap.client.Config: dap.Configuration
257257
---@field type string The dap adapter to use
258258
---@field name string
259259
---@field request rustaceanvim.dap.config.requests.launch | rustaceanvim.dap.config.requests.attach | rustaceanvim.dap.config.requests.custom The type of dap session

lua/rustaceanvim/config/internal.lua

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ local function load_dap_configuration(type)
4444
stopOnEntry = false,
4545
}
4646
if type == 'lldb' then
47+
---@diagnostic disable-next-line: inject-field
4748
dap_config.runInTerminal = true
4849
end
4950
---@diagnostic disable-next-line: different-requires

lua/rustaceanvim/dap.lua

+1
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,7 @@ function M.start(args, verbose, callback, on_error)
315315
---@param value string
316316
:map(function(value)
317317
local is_json, artifact = pcall(vim.fn.json_decode, value)
318+
---@diagnostic disable-next-line: redundant-return-value
318319
return is_json, artifact
319320
end)
320321
---@param is_json boolean

lua/rustaceanvim/executors/quickfix.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ end
1010

1111
---@param lines string[]
1212
local function append_qf(lines)
13-
vim.fn.setqflist({}, 'a', { lines = { lines } })
13+
vim.fn.setqflist({}, 'a', { lines = lines })
1414
scroll_qf()
1515
end
1616

lua/rustaceanvim/neotest/init.lua

+1
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ function NeotestAdapter.build_spec(run_args)
273273
local dap = require('rustaceanvim.dap')
274274
overrides.sanitize_command_for_debugging(runnable.args.cargoArgs)
275275
local future = nio.control.future()
276+
---@diagnostic disable-next-line: invisible
276277
dap.start(runnable.args, false, function(strategy)
277278
future.set(strategy)
278279
end, function(err)

0 commit comments

Comments
 (0)