Skip to content

Commit 59bc46c

Browse files
committed
wip
1 parent 787028a commit 59bc46c

File tree

24 files changed

+1107
-630
lines changed

24 files changed

+1107
-630
lines changed

packages/codemirror-lang-leiden-plus/src/snippets.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {Snippets} from "@leiden-plus/lib/language";
22

3-
export const snippets: Snippets = {
3+
export const snippets = {
44
vestigChars: {
55
template: "vestig.${num}char",
66
completion: {
@@ -1159,4 +1159,4 @@ export const snippets: Snippets = {
11591159
}
11601160

11611161

1162-
}
1162+
} satisfies Snippets

packages/codemirror-lang-leiden-trans/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
"module": "dist/index.js",
1212
"exports": {
1313
"import": "./dist/index.js",
14-
"require": "./dist/index.cjs"
14+
"require": "./dist/index.cjs",
15+
"types": "./dist/index.d.ts"
1516
},
1617
"types": "dist/index.d.ts",
1718
"sideEffects": false,
@@ -26,6 +27,8 @@
2627
},
2728
"dependencies": {
2829
"@codemirror/language": "^6.10.8",
30+
"@codemirror/state": "^6.5.2",
31+
"@codemirror/commands": "^6.8.0",
2932
"@leiden-plus/lib": "workspace:*",
3033
"@leiden-plus/linter-leiden-trans": "workspace:*",
3134
"@leiden-plus/parser-leiden-trans": "workspace:*",

packages/codemirror-lang-leiden-trans/src/index.ts

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
import {LanguageSupport, LRLanguage, syntaxHighlighting} from "@codemirror/language";
1+
import {
2+
continuedIndent,
3+
delimitedIndent, foldInside, foldNodeProp,
4+
indentNodeProp,
5+
LanguageSupport,
6+
LRLanguage,
7+
syntaxHighlighting,
8+
TreeIndentContext
9+
} from "@codemirror/language";
210
import {parser} from "@leiden-plus/parser-leiden-trans";
311
import {leidenTransLinterExtension} from "@leiden-plus/linter-leiden-trans";
412
import {
@@ -16,7 +24,24 @@ export {
1624

1725
export const leidenTranslationLanguage = LRLanguage.define({
1826
parser: parser.configure({
19-
props: [leidenTranslationHighlighting],
27+
props: [
28+
leidenTranslationHighlighting,
29+
indentNodeProp.add({
30+
// "P": continuedIndent({units: 2})
31+
"Document": continuedIndent(),
32+
Translation(context) {
33+
let closed = /^\s*=T>/.test(context.textAfter)
34+
return context.lineIndent(context.node.from) + (closed ? 0 : context.unit)
35+
},
36+
P(context) {
37+
let closed = /^\s*=>/.test(context.textAfter)
38+
return context.lineIndent(context.node.from) + (closed ? 0 : context.unit)
39+
}
40+
}),
41+
foldNodeProp.add({
42+
"Translation Div P": foldInside
43+
})
44+
],
2045
})
2146
})
2247

@@ -27,4 +52,7 @@ export function leidenTranslation() {
2752
leidenTransLinterExtension,
2853
highlightActiveNode
2954
]
30-
}
55+
}
56+
57+
export {snippets} from './snippets.js'
58+
export {inlineContentAllowed, addTranslation, TranslationSnippetKey, canAddDivision, addDivision, DivisionSnippetKey} from './syntax.js'
Lines changed: 267 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,267 @@
1+
import {Snippets} from "@leiden-plus/lib/language";
2+
3+
export const snippets = {
4+
translation: {
5+
template: "<T=\n ${}\n=T>",
6+
completion: {
7+
label: "<T=${translation}=T>",
8+
displayLabel: "Translation",
9+
detail: "no language specified",
10+
info: "<T= translation =T>"
11+
}
12+
},
13+
translationWithLanguage: {
14+
template: "<T=.${language id}\n ${}\n=T>",
15+
completion: {
16+
label: "<T=.${langId} ${translation}=T>",
17+
displayLabel: "Translation",
18+
detail: "other language",
19+
info: "<T=.lang translation =T>"
20+
}
21+
},
22+
translationEnglish: {
23+
template: "<T=.en\n ${}\n=T>",
24+
completion: {
25+
label: "<T=.en ${translation}=T>",
26+
displayLabel: "Translation",
27+
detail: "English",
28+
info: "<T=.en translation =T>"
29+
}
30+
},
31+
translationGerman: {
32+
template: "<T=.de\n ${}\n=T>",
33+
completion: {
34+
label: "<T=.de ${translation}=T>",
35+
displayLabel: "Translation",
36+
detail: "German",
37+
info: "<T=.de ... =T>"
38+
}
39+
},
40+
41+
division: {
42+
template: "<D=.${n} \n <=\n ${division text}\n =>\n=D>",
43+
completion: {
44+
label: "<D=.${n} <= ${division text} =>=D>",
45+
displayLabel: "Division",
46+
detail: "other",
47+
info: "<D=.n <= ... => =D>"
48+
}
49+
},
50+
divisionRecto: {
51+
template: "<D=.r \n <=\n ${division text}\n =>\n=D>",
52+
completion: {
53+
label: "<D=.r <= ${division text} =>=D>",
54+
displayLabel: "Division",
55+
detail: "Recto",
56+
info: "<D=.r <= ... => =D>"
57+
}
58+
},
59+
divisionVerso: {
60+
template: "<D=.v \n <=\n ${division text}\n =>\n=D>",
61+
completion: {
62+
label: "<D=.v <= ${division text} =>=D>",
63+
displayLabel: "Division",
64+
detail: "Verso",
65+
info: "<D=.v <= ... => =D>"
66+
}
67+
},
68+
divisionFragment: {
69+
template: "<D=.${a}.fragment \n <=\n ${division text}\n =>\n=D>",
70+
completion: {
71+
label: "<D=.${a}.fragment <= ${division text} =>=D>",
72+
displayLabel: "Division",
73+
detail: "Fragment",
74+
info: "<D=.a.fragment <= ... => =D>"
75+
}
76+
},
77+
divisionColumn: {
78+
template: "<D=.${i}.column \n <=\n ${division text}\n =>\n=D>",
79+
completion: {
80+
label: "<D=.${i}.column <= ${division text} =>=D>",
81+
displayLabel: "Division",
82+
detail: "Column",
83+
info: "<D=.i.column <= ... => =D>"
84+
}
85+
},
86+
divisionOtherType: {
87+
template: "<D=.${n}.${type} \n <=\n ${division text}\n =>\n=D>",
88+
completion: {
89+
label: "<D=.${n}.${type} <= ${division text} =>=D>",
90+
displayLabel: "Division",
91+
detail: "other type",
92+
info: "<D=.n.type <= ... => =D>"
93+
}
94+
},
95+
96+
block: {
97+
template: "<=\n ${}\n=>",
98+
completion: {
99+
label: "<=\n ${text}\n=>",
100+
displayLabel: "Block",
101+
info: "<= text =>"
102+
}
103+
},
104+
105+
milestoneLineNumber: {
106+
template: "((${num}))",
107+
completion: {
108+
label: "((${num}))",
109+
displayLabel: "Milestone line number",
110+
info: "((1))"
111+
}
112+
},
113+
milestoneLineNumberBreak: {
114+
template: "(((${num})))",
115+
completion: {
116+
label: "(((${num})))",
117+
displayLabel: "Milestone line number",
118+
detail: "with break",
119+
info: "(((1)))"
120+
}
121+
},
122+
123+
lacuna: {
124+
template: "[...]",
125+
completion: {
126+
label: "[...]",
127+
displayLabel: "Lacuna (lost text)",
128+
detail: "",
129+
info: "[...]"
130+
}
131+
},
132+
omitted: {
133+
template: "...",
134+
completion: {
135+
label: "...",
136+
displayLabel: "Omitted",
137+
detail: "illegible or otherwise untranslatable",
138+
info: "..."
139+
}
140+
},
141+
deletion: {
142+
template: "〚${deleted text}〛",
143+
completion: {
144+
label: "〚${deleted text}〛",
145+
displayLabel: "Deleted text",
146+
info: "⟦abc⟧"
147+
}
148+
},
149+
term: {
150+
template: "<${translation}=${term}>",
151+
completion: {
152+
label: "<${translation}=${term}>",
153+
displayLabel: "Term definition",
154+
detail: "without language",
155+
info: "<definition=term>"
156+
}
157+
},
158+
termWithLanguage: {
159+
template: "<${translation}~{language id}=${term}>",
160+
completion: {
161+
label: "<${translation}~{language id}=${term}>",
162+
displayLabel: "Term definition",
163+
detail: "other language",
164+
info: "<definition~lang=translation>"
165+
}
166+
},
167+
168+
termLatin: {
169+
template: "<${translation}~la=${term}>",
170+
completion: {
171+
label: "<${translation}~la=${term}>",
172+
displayLabel: "Term definition",
173+
detail: "Latin term",
174+
info: "<definition~la=translation>"
175+
}
176+
},
177+
178+
termGreek: {
179+
template: "<${translation}~grc=${term}>",
180+
completion: {
181+
label: "<${translation}~grc=${term}>",
182+
displayLabel: "Term definition",
183+
detail: "Greek term",
184+
info: "<definition~grc=translation>"
185+
}
186+
},
187+
188+
189+
foreign: {
190+
template: "~|${foreign text}|~${lang} ",
191+
completion: {
192+
label: "~|${foreign text}|~${lang} ",
193+
displayLabel: "Foreign text",
194+
detail: "other language",
195+
info: "~|ϣ|~cop"
196+
}
197+
},
198+
foreignLatin: {
199+
template: "~|${latin text}|~la ",
200+
completion: {
201+
label: "~|${latin text}|~la ",
202+
displayLabel: "Foreign text",
203+
detail: "Latin",
204+
info: "~|abc|~la"
205+
}
206+
},
207+
foreignGreek: {
208+
template: "~|${greek text}|~grc ",
209+
completion: {
210+
label: "~|${greek text}|~grc ",
211+
displayLabel: "Foreign text",
212+
detail: "Greek",
213+
info: "~|αβγ|~grc"
214+
}
215+
},
216+
217+
218+
note: {
219+
template: "/*${note text}*/",
220+
completion: {
221+
label: "/*${note text}*/",
222+
displayLabel: "Note",
223+
info: "/*abc*/"
224+
}
225+
},
226+
227+
apparatusEntry: {
228+
template: "<:${lemma}|${reference}:${note}|:>",
229+
completion: {
230+
label: "<:${lemma}|${reference}:${note}|:>",
231+
displayLabel: "Apparatus entry",
232+
detail: "other reference",
233+
info: "<:lemma|BGU:note|:>"
234+
}
235+
},
236+
237+
apparatusEntryBGU: {
238+
template: "<:${lemma}|BGU:${note}|:>",
239+
completion: {
240+
label: "<:${lemma}|BGU:${note}|:>",
241+
displayLabel: "Apparatus entry",
242+
detail: "BGU",
243+
info: "<:lemma|BGU:note|:>"
244+
}
245+
},
246+
247+
apparatusEntryBGUDDbDP: {
248+
template: "<:${lemma}|BGU_DDbDP:${note}|:>",
249+
completion: {
250+
label: "<:${lemma}|BGU_DDbDP:${note}|:>",
251+
displayLabel: "Apparatus entry",
252+
detail: "BGU-DDbDP",
253+
info: "<:lemma|BGU_DDbDP:note|:>"
254+
}
255+
},
256+
257+
apparatusEntryNoRef: {
258+
template: "<:${lemma}|:${note}|:>",
259+
completion: {
260+
label: "<:${lemma}|:${note}|:>",
261+
displayLabel: "Apparatus entry",
262+
detail: "no reference",
263+
info: "<:lemma|:note|:>"
264+
}
265+
},
266+
267+
} satisfies Snippets

0 commit comments

Comments
 (0)