Skip to content

Commit dfd18f1

Browse files
committed
upvalue decoration
1 parent c9c5de1 commit dfd18f1

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

src/annotator.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,21 @@ import * as notifications from "./notifications";
77
let D_PARAM:vscode.TextEditorDecorationType;
88
let D_GLOBAL:vscode.TextEditorDecorationType;
99
let D_DOC_TYPE:vscode.TextEditorDecorationType;
10+
let D_UPVALUE:vscode.TextEditorDecorationType;
1011

11-
function createDecoration(key: string): vscode.TextEditorDecorationType {
12+
function createDecoration(key: string, config: vscode.DecorationRenderOptions|undefined = undefined): vscode.TextEditorDecorationType {
1213
let color = vscode.workspace.getConfiguration("emmylua").get(key);
13-
return vscode.window.createTextEditorDecorationType({
14-
light: {
15-
color: color
16-
},
17-
dark: {
18-
color: color
19-
}
20-
});
14+
config = config || {};
15+
config.light = { color: color};
16+
config.dark = { color: color};
17+
return vscode.window.createTextEditorDecorationType(config);
2118
}
2219

2320
function updateDecorations() {
2421
D_PARAM = createDecoration("colors.parameter");
2522
D_GLOBAL = createDecoration("colors.global");
2623
D_DOC_TYPE = createDecoration("colors.doc_type");
24+
D_UPVALUE = createDecoration("", { textDecoration: "underline" });
2725
}
2826

2927
export function onDidChangeConfiguration(client: LanguageClient) {
@@ -50,6 +48,7 @@ function requestAnnotatorsImpl(editor: vscode.TextEditor, client: LanguageClient
5048
map.set(AnnotatorType.DocType, []);
5149
map.set(AnnotatorType.Param, []);
5250
map.set(AnnotatorType.Global, []);
51+
map.set(AnnotatorType.Upvalue, []);
5352

5453
list.forEach(data => {
5554
let uri = vscode.Uri.parse(data.uri);
@@ -83,5 +82,8 @@ function updateAnnotators(editor: vscode.TextEditor, type: AnnotatorType, ranges
8382
case AnnotatorType.DocType:
8483
editor.setDecorations(D_DOC_TYPE, ranges);
8584
break;
85+
case AnnotatorType.Upvalue:
86+
editor.setDecorations(D_UPVALUE, ranges);
87+
break;
8688
}
8789
}

src/notifications.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ export interface AnnotatorParams {
77
export enum AnnotatorType {
88
Param,
99
Global,
10-
DocType
10+
DocType,
11+
Upvalue,
1112
}
1213

1314
export interface IAnnotator {

0 commit comments

Comments
 (0)