Sublime Forum

[✅ SOLVED] Make "Goto Anything" respects "nested" .gitignore files

#1

My company use Lerna to manage internal UIKit.

The structure is a bit like this:

root/
 |-- .gitignore
 |-- uikit/
 |    |-- .gitignore
 |    |-- <project files & dirs >
 |-- uikit-v2/
 |    |-- .gitignore
 |    |-- <v2 project files & dirs>
 |-- <other packages>
  • If .gitignore in v2 contains directory esm, dev, it will ignore that directory exclusive to uikit-v2 folder.
  • If .gitignore in root contains file index.js, it will ignore the file for all projects (because it is root)

Can you add the option to enable this to Sublime Text? Currently it is only respect the “root.gitignore.
Or is there Package that I don’t know enables this feature?

Thanks :slight_smile:

0 Likes

#2

It’s not clear what you mean by “enable this”. What specific feature are you looking for?

0 Likes

#3

sorry if I am not clear,
the feature I am asking is this:


There is folder_exclude_patterns for Sublime settings, but including the esm, cjs and dev there feels not ideal because what if in different project, I need Goto Anything to search inside dev?

I hope that clears my request.

0 Likes

#4

Oh, I now know what is not clear.

What I am asking is for “Goto Anything…” to respect the nested gitignore.

Edited the title to clear that up.

0 Likes

#5

The other part of the confusion is that goto-anything doesn’t respect gitignore at all, nesting or otherwise. This comes from gitignore files not being hidden in the side-bar.

0 Likes

#6

I see… Is it the case too with Dev Build of Sublime?

I use Dev (4102) and there is option to index_exclude_gitignore, and I thought Goto Anything shows the result of indexing?

https://www.sublimetext.com/docs/indexing.html#ver-dev

Sorry if this question is the result of my ignorance @bschaaf

0 Likes

#7

Indexing extracts symbols for goto-definition and goto-reference, it’s separate from the list of files.

0 Likes

#8

Thank you for the explanation.

So, I’ve found the best approach for now by using:

"binary_file_patterns": [..., "node_modules/", "esm/", "cjs/", "dev/"]

They are at least not included in Goto Anything, but if I need to access them I can use sidebar.

0 Likes

#9

That’s fine, I guess, but I’m wondering if you realized you can put things (e.g. "folder_exclude_patterns") into your Project file, and they’ll apply only to that project.

You can then either add your *.sublime-project to the repo so that other people using it can take advantage of your tweaks, or you can .gitignore it away. If you really want to hide the fact that you’re using a Project in ST, you can add *.sublime-project to .git/info/exclude to ignore it just on your computer.

0 Likes

#10

Thanks for the idea.

I am using Project Manager package, and because of that I don’t grok the concept of «Project» in Sublime Text.

I read the unofficial docs about Projects, read the docs for the package, and watch the awesome video about Projects by @OdatNurd. I found the solution by adding project specific settings.

Thanks all! Problem solved :slight_smile:

2 Likes