Skip to content

Commit dabd8c7

Browse files
committed
some changes for languageconfiguration
1 parent d4da02c commit dabd8c7

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

src/extension.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,9 +235,9 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
235235
vscode.workspace.registerTextDocumentContentProvider(OBJECTSCRIPT_FILE_SCHEMA, documentContentProvider),
236236
vscode.workspace.registerTextDocumentContentProvider(OBJECTSCRIPTXML_FILE_SCHEMA, xmlContentProvider),
237237
vscode.workspace.registerFileSystemProvider(FILESYSTEM_SCHEMA, fileSystemProvider, { isCaseSensitive: true }),
238-
vscode.languages.setLanguageConfiguration("objectscript-class", getLanguageConfiguration()),
239-
vscode.languages.setLanguageConfiguration("objectscript", getLanguageConfiguration()),
240-
vscode.languages.setLanguageConfiguration("objectscript-macros", getLanguageConfiguration()),
238+
vscode.languages.setLanguageConfiguration("objectscript-class", getLanguageConfiguration("class")),
239+
vscode.languages.setLanguageConfiguration("objectscript", getLanguageConfiguration("routine")),
240+
vscode.languages.setLanguageConfiguration("objectscript-macros", getLanguageConfiguration("routine")),
241241
vscode.languages.registerDocumentSymbolProvider(
242242
documentSelector("objectscript-class"),
243243
new ObjectScriptClassSymbolProvider()

src/languageConfiguration.ts

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,23 @@ import { IndentAction, LanguageConfiguration } from "vscode";
22

33
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;
44

5-
export function getLanguageConfiguration(): LanguageConfiguration {
5+
export function getLanguageConfiguration(lang: string): LanguageConfiguration {
66
return {
77
wordPattern: WORD_PATTERN,
88
brackets: [["{", "}"], ["(", ")"], ['"', '"']],
99
comments: {
10-
lineComment: "#;",
10+
lineComment: lang === "class" ? "//" : "#;",
1111
blockComment: ["/*", "*/"],
1212
},
13-
onEnterRules: [
14-
{
15-
beforeText: /^\/\/\//,
16-
afterText: /.*/,
17-
action: { indentAction: IndentAction.None, appendText: "/// " },
18-
},
19-
],
13+
onEnterRules:
14+
lang === "class"
15+
? [
16+
{
17+
beforeText: /^\/\/\//,
18+
afterText: /.*/,
19+
action: { indentAction: IndentAction.None, appendText: "/// " },
20+
},
21+
]
22+
: [],
2023
};
2124
}

0 commit comments

Comments
 (0)