rust-lang / rust-enhanced

The official Sublime Text 4 package for the Rust Programming Language
MIT License
785 stars 105 forks source link

Feature request: automatically ignore/hide `target/` and `Cargo.lock` when opening folder #137

Open LukasKalbertodt opened 7 years ago

LukasKalbertodt commented 7 years ago

I work on many small Cargo projects and open those projects in sublime simply by opening the folder (e.g. subl my-project/). Since there are so many, I don't want to tweak/create the .sublime-project file for every project. But I would like to ignore the target/ folder and Cargo.lock. I never want to open any of those in sublime. I wonder if there is a way for this plugin to automatically tell Sublime to ignore those files/folders, whenever a Cargo project is opened in sublime.

To be precise: after opening a folder containing a Cargo.toml in sublime, I want the same behavior as if I had created a .sublime-project file containing:

{
    "folders":
    [
        "file_exclude_patterns": ["Cargo.lock"],
        "folder_exclude_patterns": ["target"]
    ]
}

Meta:

Sublime Text Version

Sublime Text 3 (Build 3126)

Rust Enhanced Version

v1.0.2

ark- commented 7 years ago

While a little rough, my solution was to add:

"binary_file_patterns":
    [
        "target/**"
    ],

To my user preferences.sublime-settings. This is an acceptable solution as it's unlikely I'll want to index a folder named "target" in my searches.

I thought you'd be able to set the "Syntax Specific Settings" which in this case would be a file named RustEnchanced.sublime-settings... but I couldn't get it to work.

dten commented 7 years ago

nice find

was trying this before you edited and was gonna post saying I don't think it works syntax specific which is a shame

definitely adding this to my settings

ark- commented 7 years ago

Yup sorry for ninja edit. Tried it after I typed it to find it wasn't working.

jasonwilliams commented 7 years ago

@dten @ark- i had a try with this but couldn't get it working, do you know if we can set some syntax specific settings from a package? @wbond ?

wbond commented 7 years ago

Syntax-specific settings are applied to a view (editor buffer), so logically they can't affect application/project settings, which is what the *_patterns settings are.

If the use case is you want to just use subl, then setting the patterns globally is going to be the solution.