diff options
author | Khangal <khangaljargal@gmail.com> | 2020-04-21 21:16:58 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-21 15:16:58 +0200 |
commit | 0c637898f991ff9b90e695065a0136dd9c37106a (patch) | |
tree | 23e541a83cf99a33b0a72e632f5dbe02db239482 /runtime/lua/vim/lsp/callbacks.lua | |
parent | 2a5d766581e8be0908d4d045d3bb9fa56a821b63 (diff) | |
download | rneovim-0c637898f991ff9b90e695065a0136dd9c37106a.tar.gz rneovim-0c637898f991ff9b90e695065a0136dd9c37106a.tar.bz2 rneovim-0c637898f991ff9b90e695065a0136dd9c37106a.zip |
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>
Diffstat (limited to 'runtime/lua/vim/lsp/callbacks.lua')
-rw-r--r-- | runtime/lua/vim/lsp/callbacks.lua | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/runtime/lua/vim/lsp/callbacks.lua b/runtime/lua/vim/lsp/callbacks.lua index b6396f5798..bcadd0e2c3 100644 --- a/runtime/lua/vim/lsp/callbacks.lua +++ b/runtime/lua/vim/lsp/callbacks.lua @@ -112,11 +112,20 @@ local function location_callback(_, method, result) local _ = log.info() and log.info(method, 'No location found') return nil end - util.jump_to_location(result[1]) - if #result > 1 then - util.set_qflist(util.locations_to_items(result)) - api.nvim_command("copen") - api.nvim_command("wincmd p") + + -- 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]) + + if #result > 1 then + util.set_qflist(util.locations_to_items(result)) + api.nvim_command("copen") + api.nvim_command("wincmd p") + end + else + util.jump_to_location(result) end end |