Skip to content

Commit

Permalink
Made tmLanguage insertion scope an input parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
dariusf committed May 1, 2015
1 parent 5683696 commit ab15c53
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def __init__(self, regex, value):
self.name = "%s_%d" % (self.name, Keyword.count)
Keyword.count += 1

def process_tmLanguage(scheme_name, path, keywords):
def process_tmLanguage(scheme_name, path, keywords, insertion_scope):
plist = plistlib.readPlist(path)

plist['name'] = scheme_name
Expand All @@ -138,7 +138,11 @@ def process_tmLanguage(scheme_name, path, keywords):
'match': keyword.regex,
'name': 'meta.other.%s.%s' % (scheme_name, keyword.name)
}
plist['repository']['inline']['patterns'].append({
# insert under the desired scope
insertion_point = plist
for scope in insertion_scope.split(r'.'):
insertion_point = insertion_point[scope]
insertion_point.append({
'include': '#%s' % (keyword.name)
})

Expand Down Expand Up @@ -260,13 +264,10 @@ def generate_derived_files(self, theme_name, keyword_map, settings_map):
# collect information from data structures
keywords = [Keyword(regex, value) for (regex, value) in keyword_map.items()]

process_tmLanguage(theme_name, derived_language_path, keywords)
process_tmLanguage(theme_name, derived_language_path, keywords, self.data["deriving"]["tmLanguage_scope"])
process_tmTheme(theme_name, derived_theme_path, keywords)
process_sublime_settings(theme_name, derived_settings_path, settings_map)

# print(derived_theme_path)
# print(read_file(derived_theme))

def generate_non_derived_files(self, autocompletion, themename, settings_map, extensions, theme_scopes, keywords, keyword_map, count):
for key in list(keyword_map.keys()):
regex = key
Expand Down

0 comments on commit ab15c53

Please sign in to comment.