From 219584a6efd32d0478dcd62b501c348bc44d9d43 Mon Sep 17 00:00:00 2001 From: Nghia Le Minh Date: Sun, 25 Jun 2023 05:11:35 +0700 Subject: [PATCH] fix(lsp_dynamic_workspace_symbols): add prefilter as per documentation (after to_fuzzy_refine) (#2584) * fix(lsp_dynamic_workspace_symbols): add prefilter as per documentation (after to_fuzzy_refine) * [docgen] Update doc/telescope.txt skip-checks: true * docs grammar * [docgen] Update doc/telescope.txt skip-checks: true --------- Co-authored-by: Github Actions Co-authored-by: James Trew --- doc/telescope.txt | 29 ++++++++++++++++++++++++++--- lua/telescope/actions/init.lua | 22 ++++++++++++++++------ lua/telescope/builtin/init.lua | 2 +- 3 files changed, 43 insertions(+), 10 deletions(-) diff --git a/doc/telescope.txt b/doc/telescope.txt index a6c1e64..5d88c1a 100644 --- a/doc/telescope.txt +++ b/doc/telescope.txt @@ -1657,7 +1657,8 @@ builtin.lsp_dynamic_workspace_symbols({opts}) *telescope.builtin.lsp_dynamic_wor Dynamically lists LSP for all workspace symbols - Default keymaps: - ``: show autocompletion menu to prefilter your query by type of - symbol you want to see (i.e. `:variable:`) + symbol you want to see (i.e. `:variable:`), only works after refining + to fuzzy search using Parameters: ~ @@ -3168,6 +3169,17 @@ action_set.scroll_previewer({prompt_bufnr}, {direction}) *telescope.actions.set. {direction} (number) The direction of the scrolling +action_set.scroll_horizontal_previewer({prompt_bufnr}, {direction}) *telescope.actions.set.scroll_horizontal_previewer()* + Scrolls the previewer to the left or right. Defaults to a half page scroll, + but can be overridden using the `scroll_speed` option in `layout_config`. + See |telescope.layout| for more details. + + + Parameters: ~ + {prompt_bufnr} (number) The prompt bufnr + {direction} (number) The direction of the scrolling + + action_set.scroll_results({prompt_bufnr}, {direction}) *telescope.actions.set.scroll_results()* Scrolls the results up or down. Defaults to a half page scroll, but can be overridden using the `scroll_speed` option in `layout_config`. See @@ -3179,6 +3191,17 @@ action_set.scroll_results({prompt_bufnr}, {direction}) *telescope.actions.set.sc {direction} (number) The direction of the scrolling +action_set.scroll_horizontal_results({prompt_bufnr}, {direction}) *telescope.actions.set.scroll_horizontal_results()* + Scrolls the results to the left or right. Defaults to a half page scroll, + but can be overridden using the `scroll_speed` option in `layout_config`. + See |telescope.layout| for more details. + + + Parameters: ~ + {prompt_bufnr} (number) The prompt bufnr + {direction} (number) The direction of the scrolling + + ================================================================================ ACTIONS_LAYOUT *telescope.actions.layout* @@ -3455,8 +3478,8 @@ previewers.Previewer() *telescope.previewers.Previewer()* `termopen_previewer` and it can be used to send input to the terminal application, like less. - `scroll_fn` function(self, direction): Used to make scrolling work. - - `scroll_horizontal_fn` function(self, direction): Used to make - horizontal scrolling work. + - `scroll_horizontal_fn` function(self, direction): Used to make + horizontal scrolling work. diff --git a/lua/telescope/actions/init.lua b/lua/telescope/actions/init.lua index a401ec9..ee932ea 100644 --- a/lua/telescope/actions/init.lua +++ b/lua/telescope/actions/init.lua @@ -1338,20 +1338,30 @@ end ---@param prompt_bufnr number: The prompt bufnr actions.to_fuzzy_refine = function(prompt_bufnr) local line = action_state.get_current_line() - local prefix = (function() + local opts = (function() + local opts = { + sorter = conf.generic_sorter {}, + } + local title = action_state.get_current_picker(prompt_bufnr).prompt_title if title == "Live Grep" then - return "Find Word" + opts.prefix = "Find Word" elseif title == "LSP Dynamic Workspace Symbols" then - return "LSP Workspace Symbols" + opts.prefix = "LSP Workspace Symbols" + opts.sorter = conf.prefilter_sorter { + tag = "symbol_type", + sorter = opts.sorter, + } else - return "Fuzzy over" + opts.prefix = "Fuzzy over" end + + return opts end)() require("telescope.actions.generate").refine(prompt_bufnr, { - prompt_title = string.format("%s (%s)", prefix, line), - sorter = conf.generic_sorter {}, + prompt_title = string.format("%s (%s)", opts.prefix, line), + sorter = opts.sorter, }) end diff --git a/lua/telescope/builtin/init.lua b/lua/telescope/builtin/init.lua index a2cdd9e..42244d2 100644 --- a/lua/telescope/builtin/init.lua +++ b/lua/telescope/builtin/init.lua @@ -482,7 +482,7 @@ builtin.lsp_workspace_symbols = require_on_exported_call("telescope.builtin.__ls --- Dynamically lists LSP for all workspace symbols --- - Default keymaps: ---- - ``: show autocompletion menu to prefilter your query by type of symbol you want to see (i.e. `:variable:`) +--- - ``: show autocompletion menu to prefilter your query by type of symbol you want to see (i.e. `:variable:`), only works after refining to fuzzy search using ---@param opts table: options to pass to the picker ---@field fname_width number: defines the width of the filename section (default: 30) ---@field show_line boolean: if true, shows the content of the line the symbol is found on (default: false)