mirror of
https://github.com/LunarVim/LunarVim.git
synced 2025-08-29 22:29:57 +02:00
feature: make peek function work in neovim head and 0.5 (#1559)
This commit is contained in:
parent
df0da6fc75
commit
168eb232d1
1 changed files with 14 additions and 3 deletions
|
@ -54,9 +54,8 @@ local function create_floating_file(location, opts)
|
|||
return bufnr, winnr
|
||||
end
|
||||
|
||||
local function preview_location_callback(_, method, result)
|
||||
local function preview_location_callback(result)
|
||||
if result == nil or vim.tbl_isempty(result) then
|
||||
print("peek: No location found: " .. method)
|
||||
return nil
|
||||
end
|
||||
|
||||
|
@ -74,6 +73,14 @@ local function preview_location_callback(_, method, result)
|
|||
end
|
||||
end
|
||||
|
||||
local function preview_location_callback_old_signature(_, _, result)
|
||||
return preview_location_callback(result)
|
||||
end
|
||||
|
||||
local function preview_location_callback_new_signature(_, result)
|
||||
return preview_location_callback(result)
|
||||
end
|
||||
|
||||
function M.open_file()
|
||||
-- Get the file currently open in the floating window
|
||||
local filepath = vim.fn.expand "%:."
|
||||
|
@ -129,7 +136,11 @@ function M.Peek(what)
|
|||
else
|
||||
-- Make a new request and then create the new window in the callback
|
||||
local params = vim.lsp.util.make_position_params()
|
||||
local success, _ = pcall(vim.lsp.buf_request, 0, "textDocument/" .. what, params, preview_location_callback)
|
||||
local preview_callback = preview_location_callback_old_signature
|
||||
if vim.fn.has "nvim-0.5.1" > 0 then
|
||||
preview_callback = preview_location_callback_new_signature
|
||||
end
|
||||
local success, _ = pcall(vim.lsp.buf_request, 0, "textDocument/" .. what, params, preview_callback)
|
||||
if not success then
|
||||
print(
|
||||
'peek: Error calling LSP method "textDocument/' .. what .. '". The current language lsp might not support it.'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue