aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/lsp/util.lua
diff options
context:
space:
mode:
authorTom Praschan <13141438+tom-anders@users.noreply.github.com>2023-09-07 10:12:02 +0200
committerGitHub <noreply@github.com>2023-09-07 10:12:02 +0200
commit131a1ee82d15ce9d1356a46117c9a1651947d4b8 (patch)
tree2560b881a308fb508b71060cb005403e3240f040 /runtime/lua/vim/lsp/util.lua
parentec753cf40db4d326c2fbbf5e5be0d249be561a41 (diff)
downloadrneovim-131a1ee82d15ce9d1356a46117c9a1651947d4b8.tar.gz
rneovim-131a1ee82d15ce9d1356a46117c9a1651947d4b8.tar.bz2
rneovim-131a1ee82d15ce9d1356a46117c9a1651947d4b8.zip
feat(lsp): add original LSP Location as item's user_data in locations_to_items (#23743)
Diffstat (limited to 'runtime/lua/vim/lsp/util.lua')
-rw-r--r--runtime/lua/vim/lsp/util.lua6
1 files changed, 5 insertions, 1 deletions
diff --git a/runtime/lua/vim/lsp/util.lua b/runtime/lua/vim/lsp/util.lua
index 2e376f9093..a6d17afa1b 100644
--- a/runtime/lua/vim/lsp/util.lua
+++ b/runtime/lua/vim/lsp/util.lua
@@ -1812,6 +1812,9 @@ end)
--- Returns the items with the byte position calculated correctly and in sorted
--- order, for display in quickfix and location lists.
---
+--- The `user_data` field of each resulting item will contain the original
+--- `Location` or `LocationLink` it was computed from.
+---
--- The result can be passed to the {list} argument of |setqflist()| or
--- |setloclist()|.
---
@@ -1840,7 +1843,7 @@ function M.locations_to_items(locations, offset_encoding)
-- locations may be Location or LocationLink
local uri = d.uri or d.targetUri
local range = d.range or d.targetSelectionRange
- table.insert(grouped[uri], { start = range.start })
+ table.insert(grouped[uri], { start = range.start, location = d })
end
local keys = vim.tbl_keys(grouped)
@@ -1872,6 +1875,7 @@ function M.locations_to_items(locations, offset_encoding)
lnum = row + 1,
col = col + 1,
text = line,
+ user_data = temp.location,
})
end
end