Skip to content
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

feat: option ignore_paths to avoid running on certain paths #105

Merged
merged 3 commits into from
Jan 16, 2025

Conversation

rodrigoscc
Copy link

@rodrigoscc rodrigoscc commented Jan 10, 2025

When I run Neovim in directories like my home directory or the root, I may not have permission for every directory, and I might not want to run rg on such large directories.

I've seen errors like the one below because of this:

failed to get completions with error: /usr/local/share/nvim/runtime/lua/vim/_system.lua:245: ENOENT: no such file or directory

This PR introduces a configuration option called ignore_paths to prevent running rg on the specified paths.

@mikavilpas
Copy link
Owner

This seems like a good idea 👍🏻 I'm sure nobody wants to run a huge search basically ever.

Right now I think this might be addressed in a more flexible way by changing the default logic not to search if not in a project (see #103). I'd like to hear what you think about this solution.

In the meantime, maybe you could try adding a global ignore for your home directory
image

Although I think that will also disable rg on the command line on your system according to the ignore rules, so it may not be the best option. Let me know what you think!

@rodrigoscc
Copy link
Author

Users may want to search on directories that are not projects though, such as config directories like /etc/something/.

Regarding the rg config, I'd like to have a separate exclude configuration for blink-ripgrep, as they both serve completely different use cases (completion vs search).

@mikavilpas
Copy link
Owner

I agree, it would be great to be able to exclude from blink-ripgrep only and leave ripgrep unaffected on the command line.

Issue
=====

It's not possible to not search with blink-ripgrep.nvim while
maintaining the ability to search with ripgrep (outside of Neovim).

Although ripgrep supports many ways of ignoring paths, and blink-ripgrep
is affected by those, they will always affect both ripgrep and
blink-ripgrep at the same time.

Users cannot maintain the ability to search with ripgrep in the terminal
and use blink-ripgrep in Neovim at the same time.

Solution
========

Add a new option `ignore_paths` to the configuration of blink-ripgrep.
These can be set to absolute paths (resolved by `project_root_marker`).

When a search is started, the plugin will check if the root path is
ignored, and will not search if that's the case.

BREAKING CHANGE: The `get_command` function, which provides a custom way
to generate the entire ripgrep command, must now return a table with the
command and the root path.
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