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

Search hidden files when searching Project #3190

Closed
glogiotatidis opened this issue May 21, 2020 · 10 comments
Closed

Search hidden files when searching Project #3190

glogiotatidis opened this issue May 21, 2020 · 10 comments
Labels
is:support A request for user support: questions, how-to's, and discussions module:completion/helm Pertains to Doom's :completion helm module module:completion/ivy Pertains to Doom's :completion ivy module stale No response, forgotten, or abandoned status:resolved Issue was addressed internally

Comments

@glogiotatidis
Copy link
Contributor

Describe the feature
Using SPC s p should invoke rg with --hidden to search hidden files in the project too. It seems that it uses counsel-rg-base-command variable which is set to "rg" "-L" "--search-zip" "--no-heading" "--color=never"

System information

((emacs
  (version . "26.1")
  (features . "XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GSETTINGS NOTIFY ACL LIBSELINUX GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB TOOLKIT_SCROLL_BARS GTK3 X11 THREADS LIBSYSTEMD LCMS2")
  (build . "Sep 09, 2019")
  (buildopts "--build x86_64-linux-gnu --prefix=/usr --sharedstatedir=/var/lib --libexecdir=/usr/lib --localstatedir=/var/lib --infodir=/usr/share/info --mandir=/usr/share/man --enable-libsystemd --with-pop=yes --enable-locallisppath=/etc/emacs:/usr/local/share/emacs/26.1/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/26.1/site-lisp:/usr/share/emacs/site-lisp --with-sound=alsa --without-gconf --with-mailutils --build x86_64-linux-gnu --prefix=/usr --sharedstatedir=/var/lib --libexecdir=/usr/lib --localstatedir=/var/lib --infodir=/usr/share/info --mandir=/usr/share/man --enable-libsystemd --with-pop=yes --enable-locallisppath=/etc/emacs:/usr/local/share/emacs/26.1/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/26.1/site-lisp:/usr/share/emacs/site-lisp --with-sound=alsa --without-gconf --with-mailutils --with-x=yes --with-x-toolkit=gtk3 --with-toolkit-scroll-bars 'CFLAGS=-g -O2 -fdebug-prefix-map=/build/emacs-iJm1BQ/emacs-26.1+1=. -fstack-protector-strong -Wformat -Werror=format-security -Wall' 'CPPFLAGS=-Wdate-time -D_FORTIFY_SOURCE=2' LDFLAGS=-Wl,-z,relro")
  (windowsys . batch)
  (daemonp . server-running))
 (doom
  (version . "2.0.9")
  (build . "HEAD -> develop 265e80123 2020-05-19 05:35:03 -0400")
  (dir . "~/.doom.d/"))
 (system
  (type . gnu/linux)
  (config . "x86_64-pc-linux-gnu")
  (shell . "/bin/bash")
  (uname . "Linux 5.5.0-2-amd64 #1 SMP Debian 5.5.17-1 (2020-04-15) x86_64")
  (path "~/.npm-packages/bin" "~/.gems/bin" "~/git/adr-tools/src" "~/.cargo/bin" "~/.local/bin" "~/bin/" "~/node_modules/.bin/" "~/git/git-tools/" "/usr/local/sbin" "/usr/local/bin" "~/.cargo/bin" "~/bin" "/usr/local/bin" "/usr/bin" "/bin" "/usr/local/games" "/usr/games" "/snap/bin" "/usr/lib/emacs/26.1/x86_64-linux-gnu"))
 (config
  (envfile . envvar-file)
  (elc-files . 0)
  (modules :completion company ivy :ui doom doom-dashboard hl-todo indent-guides modeline ophints (popup +defaults) vc-gutter vi-tilde-fringe workspaces :editor (evil +everywhere) file-templates fold word-wrap :emacs (dired +icons +ranger) electric undo vc :term eshell :checkers syntax spell :tools ansible docker editorconfig (eval +overlay) lookup magit terraform :lang data emacs-lisp json javascript markdown (org +dragndrop +journal) python sh web yaml :email mu4e :config (default +bindings +smartparens))
  (packages (magit) (forge))
  (unpin "n/a")
  (elpa "org" "htmlize")))

@glogiotatidis glogiotatidis added the is:feature Adds or requests new features, or extends existing ones label May 21, 2020
@ymarco
Copy link
Contributor

ymarco commented May 21, 2020

I don't think --hidden should be enabled by default. When was the last time you wanted to find something in the .git directory? It might slow searching down significantly in some cases.
You can send arguments to ripgrep with -- ARGUMENTS appended to your search, so e.g hello -- --hidden would search "hello" in hidden files too.

@hlissner
Copy link
Member

hlissner commented May 21, 2020

You can tack on arguments for rg after a -- in your search query. e.g.

search terms -- -uu

-u = don't respect .gitignore or .ignore files
-uu = same as -u and show hidden files
-uuu = same as -uu and search binary files

@hlissner hlissner added module:completion/helm Pertains to Doom's :completion helm module module:completion/ivy Pertains to Doom's :completion ivy module is:support A request for user support: questions, how-to's, and discussions status:resolved Issue was addressed internally and removed is:feature Adds or requests new features, or extends existing ones labels May 21, 2020
@glogiotatidis
Copy link
Contributor Author

glogiotatidis commented May 21, 2020

Agreed about no wanting to search .git but it's very common to have configuration files on the root level of the project like .travis.yaml or .gitlab-ci.yaml which are not searched by default.

Having -- is very helpful, I still argue that searching hidden by default is the right thing to do here while excluding .git with -g !.git

Which would be the best way to make it so in my personal config?

@hlissner
Copy link
Member

hlissner commented May 21, 2020

Agreed about no wanting to search .git but it's very common to have configuration files on the root level of the project like .travis.yaml or .gitlab-ci.yaml which are not searched by default.

That makes sense. I'm tempted to add --hidden to counsel-rg-base-command's default value, but I think this should be suggested to swiper, upstream. What do you think?

Though, I don't think rg searches .git directories, with or without --hidden.

Which would be the best way to make it so in my personal config?

Add this to ~/.doom.d/config.el:

(after! counsel
  (setq counsel-rg-base-command
        "rg -M 240 --hidden --with-filename --no-heading --line-number --color never %s"))

@glogiotatidis
Copy link
Contributor Author

With --hidden it does search .git

See also BurntSushi/ripgrep#340

@glogiotatidis
Copy link
Contributor Author

but I think this should be suggested to swiper, upstream. What do you think?

Happy to file an issue upstream but I'm unsure if that should be part of the broader swiper package or only enabled when in a project (thus projectile?) (Or I could be messing things up b/c it's vague where one package ends and where the other begins.)

@wedens
Copy link

wedens commented May 23, 2020

Another similar case: sometimes I want to find file (or its content) that's ignored in .gitignore (some local config file, for example). So, it's difficult to make a single universal command that works in all scenarios.

Unfortunately, AFAIK, ivy doesn't provide any interface for "toggles". It'd be great to have some ivy+transient-like interface. It's probably doable with hydra, but it's not as nice as it could be.

@Hettomei
Copy link

Hettomei commented May 25, 2020

Hi,

If it helps, I have done this on a given key binding to always add specific params, this way I m sur I do not miss any update on counsel-rg-base-command

  (let ((counsel-rg-base-command (concat counsel-rg-base-command " -w --case-sensitive")))
    (+default/search-project-for-symbol-at-point symbol arg))

@cartesian-theatrics
Copy link

Just got bit by this one. For large projects I don't think "--hidden" is a good default. Can we make it more readily customizable?

@github-actions
Copy link

This issue has been automatically marked stale because of a lack of recent activity. If this issue is still valid, reply to it or remove the label or it will be closed in 7 days.

@github-actions github-actions bot added the stale No response, forgotten, or abandoned label Aug 24, 2021
@github-actions github-actions bot closed this as completed Sep 1, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 30, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
is:support A request for user support: questions, how-to's, and discussions module:completion/helm Pertains to Doom's :completion helm module module:completion/ivy Pertains to Doom's :completion ivy module stale No response, forgotten, or abandoned status:resolved Issue was addressed internally
Projects
None yet
Development

No branches or pull requests

6 participants