Skip to content

Commit 332c65d

Browse files
committedMar 10, 2025
color & delay config for VSCode
1 parent 28b00ac commit 332c65d

File tree

2 files changed

+45
-7
lines changed

2 files changed

+45
-7
lines changed
 

‎vscode/package.json

+30
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,36 @@
3939
"4"
4040
],
4141
"description": "The stroke thickness of the underline line"
42+
},
43+
"rustowl.lifetimeColor": {
44+
"type": "string",
45+
"default": "hsla(125, 80%, 60%, 0.6)",
46+
"description": "The color of the lifetime underline"
47+
},
48+
"rustowl.moveCallColor": {
49+
"type": "string",
50+
"default": "hsla(35, 80%, 60%, 0.6)",
51+
"description": "The color of the move/call underline"
52+
},
53+
"rustowl.immutableBorrowColor": {
54+
"type": "string",
55+
"default": "hsla(230, 80%, 60%, 0.6)",
56+
"description": "The color of the immutable borrow underline"
57+
},
58+
"rustowl.mutableBorrowColor": {
59+
"type": "string",
60+
"default": "hsla(300, 80%, 60%, 0.6)",
61+
"description": "The color of the mutable borrow underline"
62+
},
63+
"rustowl.outliveColor": {
64+
"type": "string",
65+
"default": "hsla(0, 80%, 60%, 0.6)",
66+
"description": "The color of the outlive underline"
67+
},
68+
"rustowl.displayDelay": {
69+
"type": "number",
70+
"default": 2000,
71+
"description": "Delay in displaying underlines (ms)"
4272
}
4373
}
4474
}

‎vscode/src/extension.ts

+15-7
Original file line numberDiff line numberDiff line change
@@ -53,22 +53,29 @@ export function activate(context: vscode.ExtensionContext) {
5353
);
5454
};
5555

56-
const { underlineThickness } = vscode.workspace.getConfiguration("rustowl");
56+
const {
57+
underlineThickness,
58+
lifetimeColor,
59+
moveCallColor,
60+
immutableBorrowColor,
61+
mutableBorrowColor,
62+
outliveColor,
63+
} = vscode.workspace.getConfiguration("rustowl");
5764

5865
lifetimeDecorationType = vscode.window.createTextEditorDecorationType({
59-
textDecoration: `underline solid ${underlineThickness}px hsla(125, 80%, 60%, 0.8)`,
66+
textDecoration: `underline solid ${underlineThickness}px ${lifetimeColor}`,
6067
});
6168
moveDecorationType = vscode.window.createTextEditorDecorationType({
62-
textDecoration: `underline solid ${underlineThickness}px hsla(35, 80%, 60%, 0.8)`,
69+
textDecoration: `underline solid ${underlineThickness}px ${moveCallColor}`,
6370
});
6471
imBorrowDecorationType = vscode.window.createTextEditorDecorationType({
65-
textDecoration: `underline solid ${underlineThickness}px hsla(230, 80%, 60%, 0.8)`,
72+
textDecoration: `underline solid ${underlineThickness}px ${immutableBorrowColor}`,
6673
});
6774
mBorrowDecorationType = vscode.window.createTextEditorDecorationType({
68-
textDecoration: `underline solid ${underlineThickness}px hsla(300, 80%, 60%, 0.8)`,
75+
textDecoration: `underline solid ${underlineThickness}px ${mutableBorrowColor}`,
6976
});
7077
outLiveDecorationType = vscode.window.createTextEditorDecorationType({
71-
textDecoration: `underline solid ${underlineThickness}px hsla(0, 80%, 60%, 0.8)`,
78+
textDecoration: `underline solid ${underlineThickness}px ${outliveColor}`,
7279
});
7380
emptyDecorationType = vscode.window.createTextEditorDecorationType({});
7481

@@ -134,6 +141,7 @@ export function activate(context: vscode.ExtensionContext) {
134141
);
135142
vscode.window.onDidChangeTextEditorSelection(
136143
(ev) => {
144+
const { displayDelay } = vscode.workspace.getConfiguration("rustowl");
137145
if (ev.textEditor === activeEditor) {
138146
resetDecoration();
139147
if (decoTimer) {
@@ -155,7 +163,7 @@ export function activate(context: vscode.ExtensionContext) {
155163
if (data.success) {
156164
updateDecoration(ev.textEditor, data.data);
157165
}
158-
}, 2000);
166+
}, displayDelay);
159167
}
160168
},
161169
null,

0 commit comments

Comments
 (0)