sublimehq / sublime_text

Issue tracker for Sublime Text
https://www.sublimetext.com
809 stars 39 forks source link

Exclude `.gitignore` rules from Sublime projects #2787

Open andreiborisov opened 5 years ago

andreiborisov commented 5 years ago

Problem description

A lot of unnecessary files like dependencies in node_modules for Node.js projects and build files are added to Sublime project automatically and indexed.

Preferred solution

Now since Sublime became Git aware it would be nice to automatically exclude files from Sublime project based on .gitignore rules which are usually already setup for most projects.

Alternatives

  1. Populating those rules manually is tedious and isn't really a good solution.
  2. There is a plugin for that: https://github.com/ExplodingCabbage/sublime-gitignorer. However, it's doesn't allow to toggle itself per-project which is really crucial functionality. It's also not respecting global .gitignore rules, hasn't been updated in a long time and slowing Sublime Text significantly.

Additional Information

Since folder_exclude_patterns setting does essentially the same thing as .gitignore I feel like making them to interoperate is a logical step.

keith-hall commented 5 years ago

I guess this should be customizable, because some people may want to still see such files in the sidebar, just not indexed (i.e more like index_exclude_patterns), and others may still want them indexed etc. like how it is now. So I guess somehow it would be a mix of binary_file_patterns, folder_exclude_patterns and index_exclude_patterns, which could make it harder to figure out why some files are not appearing etc. compared to how it is now

andreiborisov commented 5 years ago

I see it as an option or two. For example:

"dont_index_ignored_git_files": true,
"exclude_ignored_git_files": false

I feel like those are defaults that most people probably want. Existent *_patterns settings would overwrite those, so user can include some of the files ignored by Git.

jrappen commented 4 years ago

This was partly addressed in Build 4050.


bahoo commented 3 years ago

Just want to add my 2 pennies, I have a use-case where I want to be able to search files specified in .gitignore but not include them in source, and Sublime doesn't give me a good mechanism for that. I've set index_exclude_gitignore to false, and while it did labor quite a bit on indexing those files, I still couldn't see those files in the search results. Entirely possible this is some user error on my part, but this might be tied up in what was meant by it being 'partly' addressed.

jvican commented 3 years ago

I was really surprised to find that enabling index_exclude_gitignore didn't stop gitignored results from showing up when looking for files with Ctrl+P. I agree that making folder_exclude_patterns interoperate with .gitignore makes sense and I would argue that this should be the default because it's the most intuitive behavior (as it is in other editors and IDEs). Would it be possible to get this feature implemented any time soon?

keybits commented 3 years ago

@bahoo In ST4 when searching it's possible to toggle the index_exclude_gitignore from the search UI:

image

More here: https://forum.sublimetext.com/t/how-to-disable-this-feature/58127

Does that achieve what you're looking for?

bahoo commented 3 years ago

Oooh, clutch ! Missed that in the new UI, thank you @keybits !

getsnoopy commented 1 year ago

@jvican Exactly. What's the point of index_exclude_gitignore if the files are still going to show up in the file lookup?

What's weird is that the files/folders are nevertheless greyed out in the sidebar, so this is especially confusing. Is Sublime ignoring the files, or is it not?

deathaxe commented 1 year ago

Displaying files and indexing their content are 2 different functions.

ST manages an internal representation of all files (excluding binary_files_patterns) and folders (excluding folder_exclude_patterns) in RAM. That's the source for sidebar and Goto Anything (ctrl+p).

Indexing means to open each file (excluding index_exclude_patterns or index_exclude_gitignore), look for symbols (class names, functions, ...) and store them in a database. That's what drives "Goto Symbol in Project..." (ctrl+shift+r) or enables ST to provide symbol kind information in auto completions.

.gitignored files are greyed out to indicate they are not part of the version history. That's how ST default theme decides to display those files. It could also dispaly a batch on the right as for modified files.

getsnoopy commented 1 year ago

@deathaxe Ah, I see. Could a similar setting to index_exclude_gitignore be added for the files display? Maybe as folder_exclude_gitignore or the like?

EDIT: Actually more like goto_exclude_gitignore, since it seems like folder_exclude_pattern hides the matching folders from the sidebar as well, which is not what I want.

arg0d commented 10 months ago

I have set index_exclude_gitignore: false, but Find In Files still refuses to search for files in git ignored directory. What am I doing wrong? Build 4169.