mirror of
https://github.com/Myriad-Dreamin/tinymist.git
synced 2025-12-23 08:47:50 +00:00
feat: update way and add config about word separator (#1002)
This commit is contained in:
parent
2a42ff67f5
commit
def730f32a
5 changed files with 37 additions and 6 deletions
|
|
@ -24,6 +24,16 @@ Configure the root for absolute paths in typst. Hint: you can set the rootPath t
|
|||
|
||||
- **Type**: `string` or `null`
|
||||
|
||||
## `tinymist.configureDefaultWordSeparator`
|
||||
|
||||
Whether to configure default word separators on startup
|
||||
|
||||
- **Type**: `string`
|
||||
- **Enum**:
|
||||
- `enable`: Override the default word separators on startup
|
||||
- `disable`: Do not override the default word separators on startup
|
||||
- **Default**: `"enable"`
|
||||
|
||||
## `tinymist.semanticTokens`
|
||||
|
||||
Enable or disable semantic tokens (LSP syntax highlighting)
|
||||
|
|
|
|||
|
|
@ -308,6 +308,20 @@
|
|||
],
|
||||
"default": null
|
||||
},
|
||||
"tinymist.configureDefaultWordSeparator": {
|
||||
"title": "Configure default word separators",
|
||||
"description": "Whether to configure default word separators on startup",
|
||||
"type": "string",
|
||||
"default": "enable",
|
||||
"enum": [
|
||||
"enable",
|
||||
"disable"
|
||||
],
|
||||
"enumDescriptions": [
|
||||
"Override the default word separators on startup",
|
||||
"Do not override the default word separators on startup"
|
||||
]
|
||||
},
|
||||
"tinymist.semanticTokens": {
|
||||
"title": "Semantic tokens mode",
|
||||
"description": "Enable or disable semantic tokens (LSP syntax highlighting)",
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ function substVscodeVars(str: string | null | undefined): string | undefined {
|
|||
}
|
||||
|
||||
function determineVscodeTheme(): any {
|
||||
console.log("determineVscodeTheme", vscode.window.activeColorTheme.kind);
|
||||
// console.log("determineVscodeTheme", vscode.window.activeColorTheme.kind);
|
||||
switch (vscode.window.activeColorTheme.kind) {
|
||||
case vscode.ColorThemeKind.Dark:
|
||||
case vscode.ColorThemeKind.HighContrast:
|
||||
|
|
|
|||
|
|
@ -69,6 +69,7 @@ export async function doActivate(context: ExtensionContext): Promise<void> {
|
|||
config.supportHtmlInMarkdown = true;
|
||||
// Sets features
|
||||
extensionState.features.preview = config.previewFeature === "enable";
|
||||
extensionState.features.wordSeparator = config.configureDefaultWordSeparator !== "disable";
|
||||
extensionState.features.devKit = isDevMode || config.devKit === "enable";
|
||||
extensionState.features.dragAndDrop = config.dragAndDrop === "enable";
|
||||
extensionState.features.onEnter = !!config.onEnterEvent;
|
||||
|
|
@ -78,14 +79,18 @@ export async function doActivate(context: ExtensionContext): Promise<void> {
|
|||
let configWordSeparators = async () => {
|
||||
const wordSeparators = "`~!@#$%^&*()=+[{]}\\|;:'\",.<>/?";
|
||||
const config1 = vscode.workspace.getConfiguration("", { languageId: "typst" });
|
||||
await config1.update("editor.wordSeparators", wordSeparators, false, true);
|
||||
await config1.update("editor.wordSeparators", wordSeparators, true, true);
|
||||
const config2 = vscode.workspace.getConfiguration("", { languageId: "typst-code" });
|
||||
await config2.update("editor.wordSeparators", wordSeparators, false, true);
|
||||
await config2.update("editor.wordSeparators", wordSeparators, true, true);
|
||||
};
|
||||
// Runs configuration asynchronously to avoid blocking the activation
|
||||
configWordSeparators().catch((e) =>
|
||||
console.error("cannot change editor.wordSeparators for typst", e),
|
||||
);
|
||||
if (extensionState.features.wordSeparator) {
|
||||
configWordSeparators().catch((e) =>
|
||||
console.error("cannot change editor.wordSeparators for typst", e),
|
||||
);
|
||||
} else {
|
||||
// console.log("skip configuring word separator on startup");
|
||||
}
|
||||
|
||||
// Configures advanced language configuration
|
||||
tinymist.configureLanguage(config["typingContinueCommentsOnNewline"]);
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ interface ExtensionState {
|
|||
features: {
|
||||
task: boolean;
|
||||
devKit: boolean;
|
||||
wordSeparator: boolean;
|
||||
dragAndDrop: boolean;
|
||||
onEnter: boolean;
|
||||
preview: boolean;
|
||||
|
|
@ -22,6 +23,7 @@ interface ExtensionState {
|
|||
export const extensionState: ExtensionState = {
|
||||
features: {
|
||||
task: true,
|
||||
wordSeparator: true,
|
||||
devKit: false,
|
||||
dragAndDrop: false,
|
||||
onEnter: false,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue