-
-
Notifications
You must be signed in to change notification settings - Fork 877
Generic list_or_jump
items filtering mechanism
#3401
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I'm leaning on completely gutting some/most of our lsp picker code and opting to leverage the We're needlessly maintaining a ton of duplicate code from neovim src, manually making server requests and such. |
So how can I solve the issue without my suggested addition? |
Sorry, I didn't mean to close the issue. You can have a working solution locally? Is that just a fork? |
I have a working solution in #3402 |
Right right. |
Is your feature request related to a problem? Please describe.
Sometimes I work on a React codebase, where I frequently use
require('telescope.builtin').lsp_definitions
to go to a component's definition. Currently,lsp_definitions
opens a picker with two options:I rarely need the second option and would like to see it only if there are no other options available (e.g., "native" elements like
div
orform
). So I need to filter out certain patterns only if more than one result is available.Describe the solution you'd like
The
lsp_definitions
function callslist_or_jump
inside:telescope.nvim/lua/telescope/builtin/__lsp.lua
Lines 293 to 296 in 415af52
The
list_or_jump
function already has some form of filtering (ignoring files if they match user-given patterns):telescope.nvim/lua/telescope/builtin/__lsp.lua
Line 236 in 415af52
telescope.nvim/lua/telescope/builtin/__lsp.lua
Lines 175 to 190 in 415af52
While it helps with static patterns (meaning patterns that don't depend on any other conditions), it doesn't allow for arbitrary conditions while filtering.
I suggest adding a callback called
filter_items
that enables users to filter thevim.quickfix.entry[]
list (calleditems
in thelist_or_jump
implementation) to make it flexible for users who want to control what is presented in the picker.Judging by how many "public" functions use
list_or_jump
internally, addingfilter_items
would extend all these "public" functions in a helpful way without making a lot of changes.Describe alternatives you've considered
Any other form of "hooking" into Telescope's internals that decide what the picker will show.
Additional context
Possible implementation:
For each function in
builtin/init.lua
that useslist_or_jump
internally, add a new field---@field filter_items FilterItemsCallback: callback to filter out quickfix entries that should be ignored
The type itself:
Add a default implementation of
filter_items
in case a user didn't provide one:Call
opts.filter_items
after other filtering:How to use:
I can create a PR quickly (I already have a working version locally).
The text was updated successfully, but these errors were encountered: