mirror of
https://github.com/neovim/neovim.git
synced 2025-10-21 17:21:49 +00:00
lsp: textDocument/definition can return Location or Location[] (#12014)
* https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_definition Co-authored-by: Khangal Jargalsaikhan <khangal.j@irbis.sg>
This commit is contained in:
@@ -112,12 +112,21 @@ local function location_callback(_, method, result)
|
|||||||
local _ = log.info() and log.info(method, 'No location found')
|
local _ = log.info() and log.info(method, 'No location found')
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- textDocument/definition can return Location or Location[]
|
||||||
|
-- https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_definition
|
||||||
|
|
||||||
|
if vim.tbl_islist(result) then
|
||||||
util.jump_to_location(result[1])
|
util.jump_to_location(result[1])
|
||||||
|
|
||||||
if #result > 1 then
|
if #result > 1 then
|
||||||
util.set_qflist(util.locations_to_items(result))
|
util.set_qflist(util.locations_to_items(result))
|
||||||
api.nvim_command("copen")
|
api.nvim_command("copen")
|
||||||
api.nvim_command("wincmd p")
|
api.nvim_command("wincmd p")
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
util.jump_to_location(result)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
M['textDocument/declaration'] = location_callback
|
M['textDocument/declaration'] = location_callback
|
||||||
|
Reference in New Issue
Block a user