Skip to content

use user input to filter completion results #372

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

Merged

Conversation

williambdean
Copy link
Contributor

@williambdean williambdean commented Mar 21, 2025

Hi,

I've been enjoying using the plugin!

I've been using the RenderMarkdown toggle command recently, start with typing tog, and always get all the completion results with <Tab>. Then having to do a bunch of to get to the right one.

This will do a partial match based on the user input and show results that start with the input. Leaving an empty input will still show all results like before.

For example buf then <Tab> will get buf_enable, buf_disable, buf_toggle.

@MeanderingProgrammer
Copy link
Owner

What completion plugin do you use if any? nvim-cmp does this by default, so curious in which case you get the behavior you're seeing.

@williambdean
Copy link
Contributor Author

I use nvim-cmp a bit but turned off much of it because I found it too annoying / distracting. I didn't know it was part of that. Thanks for letting me know.

Turning on my current config, I don't seem to get this functionality. Some plugins have it so I thought it was implemented at plugin level!

If you have any resources or can point to a setup that works, that'd be helpful!

Feel free to close the issue as well

@MeanderingProgrammer
Copy link
Owner

Ah, this is a feature of cmdline completions. You'd need to add something like this to your configuration:

cmp.setup.cmdline(':', {
    mapping = cmp.mapping.preset.cmdline(),
    sources = cmp.config.sources({
      { name = 'path' }
    }, {
      { name = 'cmdline' }
    }),
})

It does look like plugins tend to add this functionality themselves as well (took a look at trouble and fzf-lua), and I don't see the harm so will add it in.

Thanks!

@MeanderingProgrammer MeanderingProgrammer merged commit 05a740f into MeanderingProgrammer:main Mar 23, 2025
@williambdean williambdean deleted the filter-completion branch March 23, 2025 08:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants