Skip to content

Commit d56ba71

Browse files
authored
fix(lsp): document_symbol uses loclist by default neovim#32070
Problem: Not able to open document symbols for different buffers Solution: Use the location list as default. To switch back to previous behavior (qflist): vim.lsp.buf.document_symbol({ loclist = false }) Fixes: neovim#31832
1 parent a6f219b commit d56ba71

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

runtime/doc/lsp.txt

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1445,12 +1445,11 @@ Lua module: vim.lsp.buf *lsp-buf*
14451445
vim.lsp.buf.definition({ on_list = on_list })
14461446
vim.lsp.buf.references(nil, { on_list = on_list })
14471447
<
1448-
1449-
If you prefer loclist instead of qflist: >lua
1448+
{loclist}? (`boolean`) Whether to use the |location-list| or the
1449+
|quickfix| list. >lua
14501450
vim.lsp.buf.definition({ loclist = true })
1451-
vim.lsp.buf.references(nil, { loclist = true })
1451+
vim.lsp.buf.references(nil, { loclist = false })
14521452
<
1453-
{loclist}? (`boolean`)
14541453

14551454
*vim.lsp.LocationOpts*
14561455
Extends: |vim.lsp.ListOpts|
@@ -1553,7 +1552,7 @@ document_highlight() *vim.lsp.buf.document_highlight()*
15531552
|hl-LspReferenceWrite|
15541553

15551554
document_symbol({opts}) *vim.lsp.buf.document_symbol()*
1556-
Lists all symbols in the current buffer in the quickfix window.
1555+
Lists all symbols in the current buffer in the |location-list|.
15571556

15581557
Parameters: ~
15591558
{opts} (`vim.lsp.ListOpts?`) See |vim.lsp.ListOpts|.

runtime/doc/news.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ LSP
2626

2727
`lsp/` runtimepath files should return a table instead of calling
2828
|vim.lsp.config()| (or assigning to `vim.lsp.config`). See |lsp-config|
29+
`vim.lsp.buf.document_symbol()` uses the |location-list| by default. Use
30+
`vim.lsp.buf.document_symbol({ loclist = false })` to use the |quickfix|
31+
list.
2932

3033

3134
OPTIONS

runtime/lua/vim/lsp/buf.lua

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -252,13 +252,13 @@ end
252252
--- vim.lsp.buf.definition({ on_list = on_list })
253253
--- vim.lsp.buf.references(nil, { on_list = on_list })
254254
--- ```
255+
--- @field on_list? fun(t: vim.lsp.LocationOpts.OnList)
255256
---
256-
--- If you prefer loclist instead of qflist:
257+
--- Whether to use the |location-list| or the |quickfix| list.
257258
--- ```lua
258259
--- vim.lsp.buf.definition({ loclist = true })
259-
--- vim.lsp.buf.references(nil, { loclist = true })
260+
--- vim.lsp.buf.references(nil, { loclist = false })
260261
--- ```
261-
--- @field on_list? fun(t: vim.lsp.LocationOpts.OnList)
262262
--- @field loclist? boolean
263263

264264
--- @class vim.lsp.LocationOpts.OnList
@@ -796,9 +796,10 @@ function M.references(context, opts)
796796
end
797797
end
798798

799-
--- Lists all symbols in the current buffer in the quickfix window.
799+
--- Lists all symbols in the current buffer in the |location-list|.
800800
--- @param opts? vim.lsp.ListOpts
801801
function M.document_symbol(opts)
802+
opts = vim.tbl_deep_extend('keep', opts or {}, { loclist = true })
802803
local params = { textDocument = util.make_text_document_params() }
803804
request_with_opts(ms.textDocument_documentSymbol, params, opts)
804805
end

0 commit comments

Comments
 (0)