diff --git a/README.md b/README.md index 3e5d5dd..f9f9787 100644 --- a/README.md +++ b/README.md @@ -11,9 +11,11 @@ Usage instructions: * Press CTRL+SHIFT+P (CMD+SHIFT+P on Mac) * Select "Install Package" * Search for the ***Gitignored File Excluder*** and press Enter. -* `sublime-gitignorer` will regularly check all your open folders for files that are ignored by Git and update your `"file_exclude_patterns"` and `"folder_exclude_patterns"` settings in Sublime to match the list of files and folders ignored by Git. +* `sublime-gitignorer` will regularly check all your open folders for files that are ignored by Git and update your `"file_exclude_patterns"`, `"folder_exclude_patterns"`, and `"binary_file_patterns"` settings in Sublime to match the list of files and folders ignored by Git. * After you create a new Git-ignored file or update your `.gitignore` files, the files should be hidden from your project within 5 seconds. -* Since the `"file_exclude_patterns"` and `"folder_exclude_patterns"` settings are now being managed programatically, if you want to *manually* set file or folder exclusion patterns in sublime, you can use the `"extra_file_exclude_patterns"` and `"extra_folder_exclude_patterns"` settings. Any file paths you list in here will automatically be included in your `"file_exclude_patterns"` and `"folder_exclude_patterns"` in addition to Git-ignored paths. -* If you already have `"file_exclude_patterns"` or `"folder_exclude_patterns"` set, there is no need to back them up prior to installing this plugin; they will be automatically migrated to the `"extra_file_exclude_patterns"` and `"extra_folder_exclude_patterns"` settings on first launch. +* Since the `"file_exclude_patterns"`, `"folder_exclude_patterns"`, and `"binary_file_patterns"` settings are now being managed programatically, if you want to *manually* set file or folder exclusion patterns in sublime, you can use the `"extra_file_exclude_patterns"`, `"extra_folder_exclude_patterns"`, and `"extra_binary_file_patterns"` settings. Any file paths you list in here will automatically be included in your `"file_exclude_patterns"`, `"folder_exclude_patterns"`, and `"binary_file_patterns"` in addition to Git-ignored paths. +* If you already have `"file_exclude_patterns"`, `"folder_exclude_patterns"`, or `"binary_file_patterns"` set, there is no need to back them up prior to installing this plugin; they will be automatically migrated to the `"extra_file_exclude_patterns"`, `"extra_folder_exclude_patterns"`, and `"extra_binary_file_patterns"` settings on first launch. + +To only ignore in GoTo Anything and not the sidebar, set `"gitignorer_only_goto_anything": true` in your settings. Currently tested on Ubuntu and Windows in Sublime Text 2 and Sublime Text 3. I haven't tested on Mac yet but it should work there too. diff --git a/gitignore_plugin.py b/gitignore_plugin.py index 772ebf0..69dd56c 100644 --- a/gitignore_plugin.py +++ b/gitignore_plugin.py @@ -43,8 +43,11 @@ def update_file_exclude_patterns(): "extra_file_exclude_patterns" and "extra_folder_exclude_patterns" settings. """ s = sublime.load_settings("Preferences.sublime-settings") + only_goto_anything = s.get('gitignorer_only_goto_anything', False) + file_exclude_patterns = s.get('extra_file_exclude_patterns', []) or [] folder_exclude_patterns = s.get('extra_folder_exclude_patterns', []) or [] + binary_file_patterns = s.get('extra_binary_file_patterns', []) or [] for path in all_ignored_paths(): is_directory = os.path.isdir(path) if platform.system() == 'Windows': @@ -57,21 +60,31 @@ def update_file_exclude_patterns(): # OS-standard separtors and include the colon after the drive letter on # Windows, so we need to convert them here to Sublime-format. path = windows_path_to_sublime_path(path) + if is_directory: - folder_exclude_patterns.append(path) + if only_goto_anything: + binary_file_patterns.append('{}/**/*'.format(path)) + else: + folder_exclude_patterns.append(path) else: - file_exclude_patterns.append(path) + if only_finder: + binary_file_patterns.append(path) + else: + file_exclude_patterns.append(path) new_files = set(file_exclude_patterns) old_files = set(s.get('file_exclude_patterns', []) or []) new_folders = set(folder_exclude_patterns) old_folders = set(s.get('folder_exclude_patterns', []) or []) + new_binary_files = set(binary_file_patterns) + old_binary_files = set(s.get('binary_file_patterns', []) or []) # Only make changes if anything has actually changed, to avoid spamming the # sublime console - if new_files != old_files or new_folders != old_folders: + if new_files != old_files or new_folders != old_folders or new_binary_files != old_binary_files: s.set('file_exclude_patterns', list(file_exclude_patterns)) s.set('folder_exclude_patterns', list(folder_exclude_patterns)) + s.set('binary_file_patterns', list(binary_file_patterns)) sublime.save_settings("Preferences.sublime-settings") def all_ignored_paths():