diff --git a/lua/telescope/builtin/__files.lua b/lua/telescope/builtin/__files.lua index 97ee6a3def..27b8d1c927 100644 --- a/lua/telescope/builtin/__files.lua +++ b/lua/telescope/builtin/__files.lua @@ -442,7 +442,7 @@ files.treesitter = function(opts) end results = utils.filter_symbols(results, opts) - if results == nil then + if vim.tbl_isempty(results) then -- error message already printed in `utils.filter_symbols` return end diff --git a/lua/telescope/builtin/__lsp.lua b/lua/telescope/builtin/__lsp.lua index af79bcb282..4f37c58458 100644 --- a/lua/telescope/builtin/__lsp.lua +++ b/lua/telescope/builtin/__lsp.lua @@ -100,7 +100,7 @@ end --- convert `item` type back to something we can pass to `vim.lsp.util.jump_to_location` --- stopgap for pre-nvim 0.10 - after which we can simply use the `user_data` --- field on the items in `vim.lsp.util.locations_to_items` ----@param item vim.lsp.util.locations_to_items.ret +---@param item vim.quickfix.entry ---@param offset_encoding string|nil utf-8|utf-16|utf-32 ---@return lsp.Location local function item_to_location(item, offset_encoding) @@ -134,9 +134,9 @@ end ---| "textDocument/implementation" ---@param action telescope.lsp.list_or_jump_action ----@param items vim.lsp.util.locations_to_items.ret[] +---@param items vim.quickfix.entry[] ---@param opts table ----@return vim.lsp.util.locations_to_items.ret[] +---@return vim.quickfix.entry[] local apply_action_handler = function(action, items, opts) if action == "textDocument/references" and not opts.include_current_line then local lnum = vim.api.nvim_win_get_cursor(opts.winnr)[1] @@ -148,9 +148,9 @@ local apply_action_handler = function(action, items, opts) return items end ----@param items vim.lsp.util.locations_to_items.ret[] +---@param items vim.quickfix.entry[] ---@param opts table ----@return vim.lsp.util.locations_to_items.ret[] +---@return vim.quickfix.entry[] local function filter_file_ignore_patters(items, opts) local file_ignore_patterns = vim.F.if_nil(opts.file_ignore_patterns, conf.file_ignore_patterns) file_ignore_patterns = file_ignore_patterns or {} @@ -242,7 +242,7 @@ local function list_or_jump(action, title, funname, params, opts) end local location = item_to_location(item, first_encoding) - vim.lsp.util.jump_to_location(location, first_encoding, opts.reuse_win) + vim.lsp.util.show_document(location, first_encoding, { reuse_win = opts.reuse_win }) else pickers .new(opts, { @@ -263,6 +263,7 @@ end lsp.references = function(opts) opts.include_current_line = vim.F.if_nil(opts.include_current_line, false) + ---@class lsp.TextDocumentPositionParams local params = vim.lsp.util.make_position_params(opts.winnr) params.context = { includeDeclaration = vim.F.if_nil(opts.include_declaration, true) } return list_or_jump("textDocument/references", "LSP References", "builtin.lsp_references", params, opts) @@ -339,7 +340,7 @@ lsp.document_symbols = function(opts) local locations = vim.lsp.util.symbols_to_items(result or {}, opts.bufnr) or {} locations = utils.filter_symbols(locations, opts, symbols_sorter) - if locations == nil then + if vim.tbl_isempty(locations) then -- error message already printed in `utils.filter_symbols` return end @@ -382,7 +383,7 @@ lsp.workspace_symbols = function(opts) local locations = vim.lsp.util.symbols_to_items(server_result or {}, opts.bufnr) or {} locations = utils.filter_symbols(locations, opts, symbols_sorter) - if locations == nil then + if vim.tbl_isempty(locations) then -- error message already printed in `utils.filter_symbols` return end @@ -424,7 +425,7 @@ local function get_workspace_symbols_requester(bufnr, opts) cancel = vim.lsp.buf_request_all(bufnr, "workspace/symbol", { query = prompt }, tx) local results = rx() ---@type table - local locations = {} ---@type vim.lsp.util.locations_to_items.ret[] + local locations = {} ---@type vim.quickfix.entry[] for _, client_res in pairs(results) do if client_res.error then diff --git a/lua/telescope/utils.lua b/lua/telescope/utils.lua index d20dbbe514..4953e9dc8c 100644 --- a/lua/telescope/utils.lua +++ b/lua/telescope/utils.lua @@ -121,7 +121,7 @@ utils.filter_symbols = function(results, opts, post_filter) msg = "Either opts.symbols or opts.ignore_symbols, can't process opposing options at the same time!", level = "ERROR", }) - return + return {} elseif not (has_ignore or has_symbols) then return results elseif has_ignore then @@ -133,7 +133,7 @@ utils.filter_symbols = function(results, opts, post_filter) msg = "Please pass ignore_symbols as either a string or a list of strings", level = "ERROR", }) - return + return {} end opts.ignore_symbols = vim.tbl_map(string.lower, opts.ignore_symbols) @@ -149,7 +149,7 @@ utils.filter_symbols = function(results, opts, post_filter) msg = "Please pass filtering symbols as either a string or a list of strings", level = "ERROR", }) - return + return {} end opts.symbols = vim.tbl_map(string.lower, opts.symbols)