-
-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(lsp/nightly): avoid deprecations with no alternative in stable (╯…
…°□°)╯︵ ┻━┻ (#587) Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
- Loading branch information
1 parent
b2df0ca
commit f116a55
Showing
17 changed files
with
247 additions
and
131 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,22 @@ | ||
local M = {} | ||
|
||
local rl = require('rustaceanvim.rust_analyzer') | ||
|
||
function M.open_external_docs() | ||
rl.buf_request(0, 'experimental/externalDocs', vim.lsp.util.make_position_params(), function(_, url) | ||
if url then | ||
local config = require('rustaceanvim.config.internal') | ||
config.tools.open_url(url) | ||
local ra = require('rustaceanvim.rust_analyzer') | ||
local clients = ra.get_active_rustaceanvim_clients(0) | ||
if #clients == 0 then | ||
return | ||
end | ||
ra.buf_request( | ||
0, | ||
'experimental/externalDocs', | ||
vim.lsp.util.make_position_params(0, clients[1].offset_encoding), | ||
function(_, url) | ||
if url then | ||
local config = require('rustaceanvim.config.internal') | ||
config.tools.open_url(url) | ||
end | ||
end | ||
end) | ||
) | ||
end | ||
|
||
return M.open_external_docs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,42 @@ | ||
local M = {} | ||
|
||
---@alias lsp_join_lines_params { textDocument: lsp_text_document, ranges: lsp_range[] } | ||
|
||
---@param visual_mode boolean | ||
---@return lsp_join_lines_params | ||
local function get_params(visual_mode) | ||
local params = visual_mode and vim.lsp.util.make_given_range_params() or vim.lsp.util.make_range_params() | ||
---@param params { textDocument: lsp_text_document, range: lsp_range } | ||
---@return { textDocument: lsp_text_document, ranges: lsp_range[] } | ||
local function modify_params(params) | ||
local range = params.range | ||
|
||
params.range = nil | ||
---@diagnostic disable-next-line: inject-field | ||
params.ranges = { range } | ||
|
||
---@diagnostic disable-next-line: return-type-mismatch | ||
return params | ||
end | ||
|
||
local function handler(_, result, ctx) | ||
vim.lsp.util.apply_text_edits(result, ctx.bufnr, vim.lsp.get_client_by_id(ctx.client_id).offset_encoding) | ||
end | ||
|
||
local rl = require('rustaceanvim.rust_analyzer') | ||
local ra = require('rustaceanvim.rust_analyzer') | ||
|
||
--- Sends the request to rust-analyzer to get the TextEdits to join the lines | ||
--- under the cursor and applies them (for use in visual mode) | ||
function M.join_lines_visual() | ||
local clients = ra.get_active_rustaceanvim_clients(0) | ||
if #clients == 0 then | ||
return | ||
end | ||
local params = modify_params(vim.lsp.util.make_given_range_params(nil, nil, 0, clients[1].offset_encoding)) | ||
ra.buf_request(0, 'experimental/joinLines', params, handler) | ||
end | ||
|
||
--- Sends the request to rust-analyzer to get the TextEdits to join the lines | ||
--- under the cursor and applies them | ||
---@param visual_mode boolean | ||
function M.join_lines(visual_mode) | ||
rl.buf_request(0, 'experimental/joinLines', get_params(visual_mode), handler) | ||
function M.join_lines() | ||
local clients = ra.get_active_rustaceanvim_clients(0) | ||
if #clients == 0 then | ||
return | ||
end | ||
local params = modify_params(vim.lsp.util.make_range_params(0, clients[1].offset_encoding)) | ||
ra.buf_request(0, 'experimental/joinLines', params, handler) | ||
end | ||
|
||
return M.join_lines | ||
return M |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.