1

I'm working in a Scala project that has target/ directories entered as ignored in the .gitignore. However, there is also Scala code being generated during the build which is being nested under a target/ directory, which I want to have included in my search. If I remove the target/ entry from .gitignore, the search picks it up (and lots of other junk). However, I don't really want to exclude these files from being ignored by Git, because they are not supposed to be committed. I just want to exclude them from being ignored by searching.

I am using the develop (prerelease 0.300) version of Spacemacs, with Helm. An example of a search command I am using is SPC s P (search project w/input) which I press while the cursor is on some identifier that I want to find in project files. I have both ag and grep installed. I don't know what Helm is using to search (maybe even git grep?).

SPC SPC describe-key RET SPC s P:

SPC s P runs the command spacemacs/helm-project-smart-do-search-region-or-symbol
(found in evil-normal-state-local-map), which is an interactive Lisp function in
‘../../funcs.el’.

It is bound to SPC *, SPC s P, M-m *, M-m s P.

(spacemacs/helm-project-smart-do-search-region-or-symbol)

Search in current project using ‘dotspacemacs-search-tools’ with
 default input.
 Search for a search tool in the order provided by ‘dotspacemacs-search-tools’.

What's the best way to essentially add a rule !foo/target/**/*.scala for the sake of search, but not of Git?

  • Can you specify the command used when you press SPC s P? – jagrg Feb 5 at 17:42
  • @jagrg Not sure, haven't got good at finding that kind of thing yet. – Keith Pinson Feb 5 at 20:30
  • 1
    Try M-x describe-key RET SPC s P. – jagrg Feb 7 at 13:45
  • @jagrg thank you. Updated the question with that info. – Keith Pinson Feb 7 at 16:35
1

Choose your tool

If you have installed ag and not rg then ag will be used according to the documentation string in your dotfile you can see that Spacemacs tries the search tool in this order first rg, then ag, pt, ack and finally grep.

Hack your tool

One solution is to use the options of the tool you are using in your case for ag:

  • create a .agignore ignore file at the root of your project
  • invoke helm-project-smart-do-search
  • when helm prompt you for the pattern to search, prefix your search pattern with -U as follow pattern: -U <pattern to search> Note that -U is an option of ag that allows you to ignore the VCS ignore files but still uses the .agignore.

Side note: for rg you can set a directory local variable RIPGREP_CONFIG_PATH with the right path to a .ripgreprc where you store the default options for the ripgrep searches in this project.

Maybe there a better way

With some efforts there should be a way to design a Spacemacs solution to organize ignore lists independently of the search tool or the VCS used. I don't know if it's very useful though most of the people like me tends to stick to same one search tool and VCS.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.