forked from intersystems-community/vscode-objectscript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlanguageConfiguration.ts
52 lines (50 loc) · 1.59 KB
/
languageConfiguration.ts
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
import { IndentAction, LanguageConfiguration } from "vscode";
export const WORD_PATTERN =
/((?<=(class|extends|as|of) )(%?\b[a-z0-9]+(\.[a-z0-9]+)*\b))|(\^[a-z0-9]+(\.[a-z0-9]+)*)|((\${1,3}|[irm]?%|\^|#)?[a-z0-9]+)/i;
export function getLanguageConfiguration(lang: string): LanguageConfiguration {
return {
wordPattern: WORD_PATTERN,
brackets: [
["{", "}"],
["(", ")"],
],
comments: {
lineComment: lang === "class" ? "//" : "#;",
blockComment: ["/*", "*/"],
},
onEnterRules:
lang === "class"
? [
{
beforeText: /^\/\/\//,
action: { indentAction: IndentAction.None, appendText: "/// " },
},
]
: [
{
beforeText: /^\s*\/\/\//,
action: { indentAction: IndentAction.None, appendText: "/// " },
},
{
beforeText: /^\s+\/\/[^/]?/,
action: { indentAction: IndentAction.None, appendText: "// " },
},
{
beforeText: /^\s+;;/,
action: { indentAction: IndentAction.None, appendText: ";; " },
},
{
beforeText: /^\s+;[^;]?/,
action: { indentAction: IndentAction.None, appendText: "; " },
},
{
beforeText: /^\s*#;/,
action: { indentAction: IndentAction.None, appendText: "#; " },
},
{
beforeText: /^\s*##;/,
action: { indentAction: IndentAction.None, appendText: "##; " },
},
],
};
}