mirror of
https://github.com/folke/snacks.nvim
synced 2025-08-05 03:08:13 +00:00
fix(picker.lsp.symbols): only include filename for search with workspace symbols
Some checks failed
CI / ci (push) Failing after 0s
Some checks failed
CI / ci (push) Failing after 0s
This commit is contained in:
parent
d10f0b6ddb
commit
eb0e5b7efe
1 changed files with 7 additions and 2 deletions
|
@ -207,7 +207,7 @@ end
|
||||||
---@alias lsp.ResultItem lsp.Symbol|lsp.CallHierarchyItem|{text?:string}
|
---@alias lsp.ResultItem lsp.Symbol|lsp.CallHierarchyItem|{text?:string}
|
||||||
---@param client vim.lsp.Client
|
---@param client vim.lsp.Client
|
||||||
---@param results lsp.ResultItem[]
|
---@param results lsp.ResultItem[]
|
||||||
---@param opts? {default_uri?:string, filter?:fun(result:lsp.ResultItem):boolean}
|
---@param opts? {default_uri?:string, filter?:(fun(result:lsp.ResultItem):boolean), text_with_file?:boolean}
|
||||||
function M.results_to_items(client, results, opts)
|
function M.results_to_items(client, results, opts)
|
||||||
opts = opts or {}
|
opts = opts or {}
|
||||||
local items = {} ---@type snacks.picker.finder.Item[]
|
local items = {} ---@type snacks.picker.finder.Item[]
|
||||||
|
@ -252,13 +252,17 @@ function M.results_to_items(client, results, opts)
|
||||||
---@type snacks.picker.finder.Item?
|
---@type snacks.picker.finder.Item?
|
||||||
local item
|
local item
|
||||||
if sym then
|
if sym then
|
||||||
|
local text = table.concat({ M.symbol_kind(result.kind), result.name, result.detail or "" }, " ")
|
||||||
|
if opts.text_with_file and sym.filename then
|
||||||
|
text = text .. " " .. sym.filename
|
||||||
|
end
|
||||||
item = {
|
item = {
|
||||||
kind = M.symbol_kind(result.kind),
|
kind = M.symbol_kind(result.kind),
|
||||||
parent = parent,
|
parent = parent,
|
||||||
depth = (parent.depth or 0) + 1,
|
depth = (parent.depth or 0) + 1,
|
||||||
detail = result.detail,
|
detail = result.detail,
|
||||||
name = result.name,
|
name = result.name,
|
||||||
text = table.concat({ M.symbol_kind(result.kind), result.name, result.detail or "", sym.filename or "" }, " "),
|
text = text,
|
||||||
file = sym.filename,
|
file = sym.filename,
|
||||||
buf = sym.bufnr,
|
buf = sym.bufnr,
|
||||||
pos = { sym.lnum, sym.col - 1 },
|
pos = { sym.lnum, sym.col - 1 },
|
||||||
|
@ -312,6 +316,7 @@ function M.symbols(opts, filt)
|
||||||
end, function(client, result, params)
|
end, function(client, result, params)
|
||||||
local items = M.results_to_items(client, result, {
|
local items = M.results_to_items(client, result, {
|
||||||
default_uri = params.textDocument and params.textDocument.uri or nil,
|
default_uri = params.textDocument and params.textDocument.uri or nil,
|
||||||
|
text_with_file = opts.workspace,
|
||||||
filter = function(item)
|
filter = function(item)
|
||||||
return want(M.symbol_kind(item.kind))
|
return want(M.symbol_kind(item.kind))
|
||||||
end,
|
end,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue