mirror of
https://github.com/folke/snacks.nvim
synced 2025-08-04 10:49:08 +00:00
fix(picker.lsp): added support for single location result
This commit is contained in:
parent
4d8d844027
commit
79d27f19dc
1 changed files with 6 additions and 0 deletions
|
@ -2,6 +2,8 @@ local Async = require("snacks.picker.util.async")
|
|||
|
||||
local M = {}
|
||||
|
||||
local islist = vim.islist or vim.tbl_islist
|
||||
|
||||
---@class snacks.picker
|
||||
---@field lsp_definitions? fun(opts?: snacks.picker.lsp.Config):snacks.Picker
|
||||
---@field lsp_implementations? fun(opts?: snacks.picker.lsp.Config):snacks.Picker
|
||||
|
@ -154,6 +156,10 @@ function M.get_locations(method, opts, filter)
|
|||
params.context = opts.context
|
||||
return params
|
||||
end, function(client, result)
|
||||
result = result or {}
|
||||
-- Result can be a single item or a list of items
|
||||
result = vim.tbl_isempty(result) and {} or islist(result) and result or { result }
|
||||
|
||||
local items = vim.lsp.util.locations_to_items(result or {}, client.offset_encoding)
|
||||
M.fix_locs(items)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue