-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathexclude_ignored.py
25 lines (22 loc) · 964 Bytes
/
exclude_ignored.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import sublime
import sublime_plugin
import os
class ExcludeIgnoredCommand(sublime_plugin.TextCommand):
def run(self, edit):
w = self.view.window()
pd = w.project_data()
for folder_setting in pd['folders']:
path = folder_setting['path']
file_patterns = [".gitignore"]
folder_patterns = []
gitignore = os.path.join(path, ".gitignore")
if (os.path.exists(gitignore)):
for pattern in open(gitignore):
pattern = pattern.strip()
if (pattern[-1] == os.sep):
folder_patterns.append(pattern[:-1])
else:
file_patterns.append(pattern)
folder_setting["file_exclude_patterns"] = file_patterns
folder_setting["folder_exclude_patterns"] = folder_patterns
w.set_project_data(pd)