Sublime Forum

Exclude folder from being analyzed

#1

I can’t seem to get the watch/indexing exclusion settings working.

I am using bazel as a build system for my project and it creates a ton of symlinks and files. All build outputs go into bzl-build folder and sublime puts a ton of load on RAM and CPU and reaches the max inotify watchers (which can’t be increased further cause the max possible setting has been reached).

I want to tell sublime to stop indexing everything in bzl-build and ignore it completely, but it doesn’t seem to work. In my Preferences.sublime-settings I have only changed index_workers to 4 to reduce any possible load (the rest of the settings are untouched)

	"folder_exclude_patterns": [".svn", ".git", ".hg", "CVS", ".Trash", ".Trash-*"],
	"file_exclude_patterns": ["*.pyc", "*.pyo", "*.exe", "*.dll", "*.obj","*.o", "*.a", "*.lib", "*.so", "*.dylib", "*.ncb", "*.sdf", "*.suo", "*.pdb", "*.idb", ".DS_Store", ".directory", "desktop.ini", "*.class", "*.psd", "*.db", "*.sublime-workspace"],
	"binary_file_patterns": ["*.jpg", "*.jpeg", "*.png", "*.gif", "*.ttf", "*.tga", "*.dds", "*.ico", "*.eot", "*.pdf", "*.swf", "*.jar", "*.zip"],
	"index_files": true,
	"index_workers": 4,
	"index_exclude_gitignore": true,
	"index_skip_unknown_extensions": true,
	"index_exclude_patterns": ["*.log"],
	"goto_anything_exclude_gitignore": false,

Since in my .gitignore I have /bzl-build/ entry and index_exclude_gitignore I would expect that sublime won’t index anything inside. However, it looks like sublime is still doing some work on the bzl-build folder, cause when I remove the folder from disk, sublime’s CPU and RAM usage go down significantly.

I also tried using the following .sublime-project, but it made little difference:

{
	"folders":
	[
		{
			"path": ".",
            "folder_exclude_patterns": ["bzl-build"],
			"index_exclude_patterns": ["bzl-build"],
		},
        {
            "path": "bzl-build",
            "file_exclude_patterns": ["*"],
            "folder_exclude_patterns": ["*"],
            "index_exclude_patterns": ["*"],
        },
	],
}

I also tried adding "*/bzl-build/*" to binary_file_patterns and set "goto_anything_exclude_gitignore": true,, but it didn’t seem to make a lot of difference.

What’s the correct way to tell sublime to completely ignore the bzl-build folder and everything inside such that sublime won’t do any work on analyzing it (equivalent to bzl-build being removed from disk)?

UPDATE: Setting index_files to false in .sublime-project doesn’t seem to make a difference either.

0 Likes

#2

The indexer is what examines the content of files to provide symbols for use in things like the global symbol list.

Your problem sounds more like Sublime is cataloging all of the files in that folder in order to display the contents of it in the side bar to allow you to navigate to it via Goto Anything

I would recommend trying a project like:

{
    "folders":
    [
        {
            "path": ".",
            "folder_exclude_patterns": ["bzl-build"],
        },
    ],
}

That is, tell it to exclude showing bzl-build in the sidebar entirely.

Your project was kind of doing that, but then you specifically added the folder back in, which may not work as intended with just * as a pattern (and is not needed if the goal is to just exclude that folder entirely).

That will stop it from trying to gather and watch all of the files in that folder, and the index_exclude_gitignore will stop it from trying to capture symbols from the intermediate output files in that folder.

0 Likes

#3

Thanks. I tried this suggestion but doesn’t seem to make a difference. The folder bzl-build still shows on the side bar in grey (the behavior is the same even without .sublime-project file since bzl-build is part of .gitignore). In the sidebar in sublime I can browse inside the bzl-build folder. It doesn’t show any files, but it shows the folders inside, which are also plenty (I would expect that proper exclusion won’t examine absolutely any content inside bzl-build). There’s still a significant CPU and RAM usage from sublime which disappear when I remove the bzl-build folder.

0 Likes

#4

If the folder is excluded, you should not see it or its contents anywhere in the side bar at all.

What does your project look like?

0 Likes

#5

.gitignore:

/bzl-build/
__pycache__/

.sublime-project:

{
    "folders":
    [
        {
            "path": ".",
            "folder_exclude_patterns": ["bzl-build"],
        },
    ],
}

Original global sublime settings posted above. Or were you asking for some other info?

0 Likes

#6

No, that was what I was asking.

So, the folder_exclude_patterns should be excluding all folders by that name from appearing under that particular path. The per-path settings augment the globals as well.

As such, if that folder is explicitly being excluded from the top level folder, then you should not see it at all in the sidebar (nor any of its contents).

The only ways that I can think of that would cause that not to happen would be:

  1. Your project specifically includes the bzl-build folder as one of the paths (which you are not doing)
  2. The sublime-project file is not stored in the root of your project directory. (based on what you’ve said, that also seems unlikely)
0 Likes

#7

Yes, you assumed correct for both 1 and 2. I am not specifically including bzl-build as a path in the project and .sublime-project is in the root of the project dir. Unfortunately, bzl-build folder still shows up in the side bar.

0 Likes

#8

Is it a symlink to another location or something, by any chance?

0 Likes