fix: adjust more to make it backward compatible for 0.11-
This commit is contained in:
@@ -18,7 +18,7 @@ function M.get_status(info)
|
||||
return { 'client: ' .. info.client.name }
|
||||
end
|
||||
|
||||
---@param client lsp.client
|
||||
---@param client vim.lsp.Client
|
||||
---@param capability string
|
||||
---@return boolean
|
||||
local function _check_client(client, capability)
|
||||
@@ -30,7 +30,7 @@ end
|
||||
|
||||
---@param bufnr integer
|
||||
---@param capability string
|
||||
---@return lsp.client?
|
||||
---@return vim.lsp.Client?
|
||||
local function get_appropriate_client(bufnr, capability)
|
||||
local clients, use_client
|
||||
|
||||
@@ -98,14 +98,22 @@ function M.request_symbols(on_symbols, opts, info)
|
||||
textDocument = l.util.make_text_document_params(),
|
||||
}
|
||||
-- XXX: Is bufnr=0 ok here?
|
||||
local status = info.client:request('textDocument/documentSymbol', params, function(err, response)
|
||||
local method = 'textDocument/documentSymbol'
|
||||
local callback = function(err, response)
|
||||
if err or not response then
|
||||
on_symbols(response, opts)
|
||||
else
|
||||
response = postprocess_symbols(response)
|
||||
on_symbols(response, opts)
|
||||
end
|
||||
end, 0)
|
||||
end
|
||||
local bufnr = 0
|
||||
local status
|
||||
if _G._outline_nvim_has[11] then
|
||||
status = info.client:request(method, params, callback, bufnr)
|
||||
else
|
||||
status = info.client.request(method, params, callback, bufnr)
|
||||
end
|
||||
if not status then
|
||||
on_symbols(nil, opts)
|
||||
end
|
||||
@@ -135,7 +143,7 @@ end
|
||||
|
||||
---@see rename_symbol
|
||||
---@param sidebar outline.Sidebar
|
||||
---@param client lsp.client
|
||||
---@param client vim.lsp.Client
|
||||
---@param node outline.FlatSymbol
|
||||
---@return boolean success
|
||||
local function legacy_rename(sidebar, client, node)
|
||||
@@ -151,8 +159,13 @@ local function legacy_rename(sidebar, client, node)
|
||||
bufnr = sidebar.code.buf,
|
||||
newName = new_name,
|
||||
}
|
||||
local status, err =
|
||||
client:request_sync('textDocument/rename', params, request_timeout, sidebar.code.buf)
|
||||
local status, err
|
||||
if _G._outline_nvim_has[11] then
|
||||
status, err = client:request_sync('textDocument/rename', params, request_timeout, sidebar.code.buf)
|
||||
else
|
||||
---@diagnostic disable-next-line
|
||||
status, err = client.request_sync('textDocument/rename', params, request_timeout, sidebar.code.buf)
|
||||
end
|
||||
if status == nil or status.err or err or status.result == nil then
|
||||
return false
|
||||
end
|
||||
@@ -211,7 +224,12 @@ function M.show_hover(sidebar)
|
||||
bufnr = sidebar.code.buf,
|
||||
}
|
||||
|
||||
local status, err = client:request_sync('textDocument/hover', params, request_timeout)
|
||||
local status, err
|
||||
if _G._outline_nvim_has[11] then
|
||||
status, err = client:request_sync('textDocument/hover', params, request_timeout)
|
||||
else
|
||||
status, err = client.request_sync('textDocument/hover', params, request_timeout)
|
||||
end
|
||||
if status == nil or status.err or err or not status.result or not status.result.contents then
|
||||
return false
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user