DFreds/code-peek-atom

Excludes directories to search in

Closed this issue · 7 comments

What do you think about adding an option to restrict some directories to search in, such as vendor for PHP or node_modules for JS?

Maybe it can help to search faster.

Thank you.

Unless I'm mistaken, it already won't search node_modules by default. At least, I can't get it to find any functions contained in a file in node_modules.

Anyway, it is a good suggestion for other folders. I'll look into it when I have the chance (or you could do it and make a pull request). This is probably the relevant function that I use: https://github.com/atom/atom/blob/v1.10.2/src/workspace.coffee#L968

Hey, so I realized that this is already sort of configurable. If you look at the scan function, it does the following:

 directoriesForSearcher.forEach (directories, searcher) =>
      searchOptions =
        inclusions: options.paths or []
        includeHidden: true
        excludeVcsIgnores: @config.get('core.excludeVcsIgnoredPaths')
        exclusions: @config.get('core.ignoredNames')
        follow: @config.get('core.followSymlinks')
        didMatch: (result) =>
          iterator(result) unless @project.isPathModified(result.filePath)
        didError: (error) ->
          iterator(null, error)
        didSearchPaths: (count) -> onPathsSearched(searcher, count)
      directorySearcher = searcher.search(directories, regex, searchOptions)
      allSearches.push(directorySearcher)

It excludes whatever you have in your core ignored names setting in Settings -> Core. I'll still look into adding a specific one for Code Peek, though.

Alternatively you could just parse .gitignore, as that's most likely the best indicator on what's not your source code.

Thank you for the answer.

It could be interesting to have a specific one for Code Peek. For example, I don't want to modify a vendor function, but I want to find the file containing the function via the Fuzzy Finder.

If I exclude the vendor directory, I won't be able to find a file into it via the Fuzzy Finder. Without autocompletion, the Fuzzy Finder is pretty useful.

@DFreds I'll try to do the modification and make a pull request, I just need to find some time to do it.

@dodekeract It actually does this if you have the Exclude VCS Ignored Paths checked in the core settings. That's why I wasn't finding anything in node_modules, because it was being ignored in my .gitignore.

@Cronos87 I'm not sure if it makes sense for you, but you could ignore the vendor folder using your .gitignore (or equivalent for you VCS) file.

Anyway, I'm thinking that the easiest way to implement this feature would be to create our own implementation of the scan function I'm currently using that is built into the Atom workspace. That way, you could change what is in the exclusions property to be a config in Code Peek. Just a thought. Let me know if you pick it up. Otherwise, I might have time this weekend to do it.

I added a configuration setting to do this. It was easier than I assumed. It should be included in 1.4.12. Thanks @Cronos87!

Reference: #13

Awesome! Thanks to you @DFreds!