From a450fda4ededdd93e3dc571d82a6737f6b9d50d9 Mon Sep 17 00:00:00 2001 From: Evgeni Chasnovski Date: Thu, 23 Jan 2025 10:42:00 +0200 Subject: fix(lsp): prefer `on_list` over `loclist` in default handler Problem: setting `loclist = true` makes `on_list` being ignored. This was not a problem before, but with `vim.lsp.buf.document_symbol` using `loclist = true` as default it is needed to explicitly pass `loclist = false` in order to use custom `on_list`. Solution: prefer `on_list` over `loclist` and document the latter as taking effect only in the default handler. --- runtime/lua/vim/lsp/handlers.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'runtime/lua/vim/lsp/handlers.lua') diff --git a/runtime/lua/vim/lsp/handlers.lua b/runtime/lua/vim/lsp/handlers.lua index 5da4033f89..a86ea99413 100644 --- a/runtime/lua/vim/lsp/handlers.lua +++ b/runtime/lua/vim/lsp/handlers.lua @@ -247,12 +247,12 @@ local function response_to_list(map_result, entity, title_fn) local items = map_result(result, ctx.bufnr) local list = { title = title, items = items, context = ctx } - if config.loclist then - vim.fn.setloclist(0, {}, ' ', list) - vim.cmd.lopen() - elseif config.on_list then + if config.on_list then assert(vim.is_callable(config.on_list), 'on_list is not a function') config.on_list(list) + elseif config.loclist then + vim.fn.setloclist(0, {}, ' ', list) + vim.cmd.lopen() else vim.fn.setqflist({}, ' ', list) vim.cmd('botright copen') -- cgit