Skip to content

Commit d2e3eb3

Browse files
committed
docs(example): Cleanup of textmate
1 parent fe91cfb commit d2e3eb3

File tree

10 files changed

+66
-74
lines changed

10 files changed

+66
-74
lines changed

example/textmate/app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def load_file(lang, file_path):
4343
# Textmate grammar definition
4444
# -----------------------------------------------------------------------------
4545

46-
state.editor_textmate = langs.to_dict()
46+
state.editor_textmate = langs.ALL_LANGS
4747

4848
# -----------------------------------------------------------------------------
4949
# GUI

example/textmate/langs/__init__.py

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,6 @@
11
from . import python, moose
22

3-
configs = {
4-
"python": python.CONFIGURATION,
5-
"moose": moose.CONFIGURATION,
6-
}
3+
ALL_LANGS = dict(languages=[], grammars={}, configs={})
74

8-
grammars = {
9-
"source.python": {
10-
"language": "python",
11-
"content": (python.GRAMMAR_TYPE, python.GRAMMAR),
12-
},
13-
"input.moose": {
14-
"language": "moose",
15-
"content": (moose.GRAMMAR_TYPE, moose.GRAMMAR),
16-
},
17-
}
18-
19-
languages = [
20-
python.LANG,
21-
moose.LANG,
22-
]
23-
24-
25-
def to_dict():
26-
return dict(
27-
languages=languages,
28-
grammars=grammars,
29-
configs=configs,
30-
)
5+
python.register_lang(ALL_LANGS)
6+
moose.register_lang(ALL_LANGS)

example/textmate/langs/moose.py

Lines changed: 0 additions & 16 deletions
This file was deleted.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
from pathlib import Path
2+
3+
CONFIGURATION = Path(__file__).with_name("moose.config.json").read_text()
4+
GRAMMAR = Path(__file__).with_name("moose.grammar.json").read_text()
5+
GRAMMAR_TYPE = "json"
6+
7+
8+
def register_lang(config):
9+
config["languages"].append(
10+
dict(
11+
id="moose",
12+
extensions=[
13+
".i",
14+
],
15+
aliases=["Moose"],
16+
filenames=[],
17+
firstLine="",
18+
)
19+
)
20+
config["configs"]["moose"] = CONFIGURATION
21+
config["grammars"]["input.moose"] = {
22+
"language": "moose",
23+
"content": (GRAMMAR_TYPE, GRAMMAR),
24+
}
File renamed without changes.
File renamed without changes.

example/textmate/langs/python.py

Lines changed: 0 additions & 30 deletions
This file was deleted.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
from pathlib import Path
2+
3+
CONFIGURATION = Path(__file__).with_name("python.config.json").read_text()
4+
GRAMMAR = Path(__file__).with_name("python.grammar.json").read_text()
5+
GRAMMAR_TYPE = "json"
6+
7+
8+
def register_lang(config):
9+
config["languages"].append(
10+
dict(
11+
id="python",
12+
extensions=[
13+
".py",
14+
".rpy",
15+
".pyw",
16+
".cpy",
17+
".gyp",
18+
".gypi",
19+
".pyi",
20+
".ipy",
21+
".bzl",
22+
".cconf",
23+
".cinc",
24+
".mcconf",
25+
".sky",
26+
".td",
27+
".tw",
28+
],
29+
aliases=["Python", "py"],
30+
filenames=["Snakefile", "BUILD", "BUCK", "TARGETS"],
31+
firstLine="^#!\\s*/?.*\\bpython[0-9.-]*\\b",
32+
)
33+
)
34+
config["configs"]["python"] = CONFIGURATION
35+
config["grammars"]["source.python"] = {
36+
"language": "python",
37+
"content": (GRAMMAR_TYPE, GRAMMAR),
38+
}
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)