-
Notifications
You must be signed in to change notification settings - Fork 3
/
bracket_highligher.py
100 lines (93 loc) · 3.06 KB
/
bracket_highligher.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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
import sublime
import sublime_plugin
bh_core_latex_settings = {
"user_scope_brackets": [
{
"name": "latexmath_block",
"open": "((?<!\\\\)\\$\\$)",
"close": "((?<!\\\\)\\$\\$)",
"style": "default",
"scopes": ["text.tex.latex meta.environment.math"],
"sub_bracket_search": True,
"enabled": True
}
],
"user_brackets": [
{
"name": "latexmath_angle",
"open": "(\\\\langle)",
"close": "(\\\\rangle)",
"style": "default",
"language_filter": "whitelist",
"language_list": ["LaTeX"],
"scope_exclude": ["comment"],
"find_in_sub_search": True,
"enabled": True
},
{
"name": "latexmath_leftright",
"open": "(\\\\left(?:[()\\[\\]|]|\\\\[{}|]|\\\\[a-zA-Z]+))",
"close": "(\\\\right(?:[()\\[\\]|]|\\\\[{}|]|\\\\[a-zA-Z]+))",
"style": "default",
"language_filter": "whitelist",
"language_list": ["LaTeX"],
"scope_exclude": ["comment"],
"find_in_sub_search": True,
"enabled": True
},
{
"name": "latexmath_square",
"open": "((?<!\\\\)\\\\\\[)",
"close": "((?<!\\\\)\\\\\\])",
"style": "square",
"language_filter": "whitelist",
"language_list": ["LaTeX"],
"scope_exclude": ["comment"],
"find_in_sub_search": True,
"enabled": True
},
{
"name": "latexmath_curly",
"open": "((?<!\\\\)\\\\\\{)",
"close": "((?<!\\\\)\\\\\\})",
"style": "curly",
"language_filter": "whitelist",
"language_list": ["LaTeX"],
"scope_exclude": ["comment"],
"find_in_sub_search": True,
"enabled": True
},
{
"name": "latexmath_round",
"open": "((?<!\\\\)\\\\\\()",
"close": "((?<!\\\\)\\\\\\))",
"style": "round",
"language_filter": "whitelist",
"language_list": ["LaTeX"],
"scope_exclude": ["comment"],
"find_in_sub_search": True,
"enabled": True
}
]
}
bh_core_settings_file = "bh_core.sublime-settings"
class LatexyzInstallBhSettings(sublime_plugin.TextCommand):
def run(self, edit, remove=False):
bh_core_settings = sublime.load_settings(bh_core_settings_file)
for k, v in bh_core_latex_settings.items():
bh_core_settings.set(k, self.merge(v, bh_core_latex_settings[k], remove))
sublime.save_settings(bh_core_settings_file)
def merge(self, old, new, remove):
out = []
for o in old:
found = False
for n in new:
if o["name"] == n["name"]:
found = True
break
if not found:
out.append(o)
if remove:
return out
else:
return out + new