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

Combination of -g and --type #75

Open
twmr opened this issue Mar 2, 2020 · 4 comments
Open

Combination of -g and --type #75

twmr opened this issue Mar 2, 2020 · 4 comments

Comments

@twmr
Copy link

twmr commented Mar 2, 2020

I would like to only grep in files with a given type and a given glob. To grep in all python files that are not unit-tests I locally run rg serachstring -tpy -g "!tests". However, it is not possible to do this using deadgrep, because the file-type in deadgrep can either be all, glob or type, but not a combination of those.

My current workaround is to override deadgrep--arguments, where I add (push "-globs=!tests" args).

twmr added a commit to twmr/dotfiles that referenced this issue Mar 2, 2020
@gvol
Copy link

gvol commented Aug 16, 2023

Would #93 solve this problem?

@twmr
Copy link
Author

twmr commented Aug 17, 2023

@gvol I guess you are asking if a custom ripgrep type defined via --add-type would solve my problem. I doubt, but I can have a closer look tmr.

@gvol
Copy link

gvol commented Aug 18, 2023

@gvol I guess you are asking if a custom ripgrep type defined via --add-type would solve my problem. I doubt, but I can have a closer look tmr.

Well, deadgrep-file-type-alist can specify any arguments to pass to rg when you choose a "type". So, you could have (untested):

(setq deadgrep-file-type-alist
      '((python "--type=python")
        (python-not-tests "--type=python" "-globs=!tests")))

and then if you choose the type of "python" it would use all python files, but if you chose "python-not-tests" it would choose only python files that aren't tests.

@twmr
Copy link
Author

twmr commented Aug 18, 2023

Then it would definitely solve my problem. Thx for bringing #93 up here!

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

No branches or pull requests

2 participants