diff options
Diffstat (limited to 'editors/code')
-rw-r--r-- | editors/code/package.json | 5 | ||||
-rw-r--r-- | editors/code/src/config.ts | 7 | ||||
-rw-r--r-- | editors/code/src/highlighting.ts | 11 |
3 files changed, 18 insertions, 5 deletions
diff --git a/editors/code/package.json b/editors/code/package.json index d8ba914f5..05c808394 100644 --- a/editors/code/package.json +++ b/editors/code/package.json | |||
@@ -164,6 +164,11 @@ | |||
164 | "default": false, | 164 | "default": false, |
165 | "description": "Highlight Rust code (overrides built-in syntax highlighting)" | 165 | "description": "Highlight Rust code (overrides built-in syntax highlighting)" |
166 | }, | 166 | }, |
167 | "rust-analyzer.rainbowHighlightingOn": { | ||
168 | "type": "boolean", | ||
169 | "default": false, | ||
170 | "description": "When highlighting Rust code, use a unique color per identifier" | ||
171 | }, | ||
167 | "rust-analyzer.showWorkspaceLoadedNotification": { | 172 | "rust-analyzer.showWorkspaceLoadedNotification": { |
168 | "type": "boolean", | 173 | "type": "boolean", |
169 | "default": true, | 174 | "default": true, |
diff --git a/editors/code/src/config.ts b/editors/code/src/config.ts index 481a5e5f1..8d73a6b34 100644 --- a/editors/code/src/config.ts +++ b/editors/code/src/config.ts | |||
@@ -15,6 +15,7 @@ export interface CargoWatchOptions { | |||
15 | 15 | ||
16 | export class Config { | 16 | export class Config { |
17 | public highlightingOn = true; | 17 | public highlightingOn = true; |
18 | public rainbowHighlightingOn = false; | ||
18 | public enableEnhancedTyping = true; | 19 | public enableEnhancedTyping = true; |
19 | public raLspServerPath = RA_LSP_DEBUG || 'ra_lsp_server'; | 20 | public raLspServerPath = RA_LSP_DEBUG || 'ra_lsp_server'; |
20 | public showWorkspaceLoadedNotification = true; | 21 | public showWorkspaceLoadedNotification = true; |
@@ -39,6 +40,12 @@ export class Config { | |||
39 | this.highlightingOn = config.get('highlightingOn') as boolean; | 40 | this.highlightingOn = config.get('highlightingOn') as boolean; |
40 | } | 41 | } |
41 | 42 | ||
43 | if (config.has('rainbowHighlightingOn')) { | ||
44 | this.rainbowHighlightingOn = config.get( | ||
45 | 'rainbowHighlightingOn' | ||
46 | ) as boolean; | ||
47 | } | ||
48 | |||
42 | if (config.has('showWorkspaceLoadedNotification')) { | 49 | if (config.has('showWorkspaceLoadedNotification')) { |
43 | this.showWorkspaceLoadedNotification = config.get( | 50 | this.showWorkspaceLoadedNotification = config.get( |
44 | 'showWorkspaceLoadedNotification' | 51 | 'showWorkspaceLoadedNotification' |
diff --git a/editors/code/src/highlighting.ts b/editors/code/src/highlighting.ts index 4597db08f..52a0bd4bb 100644 --- a/editors/code/src/highlighting.ts +++ b/editors/code/src/highlighting.ts | |||
@@ -7,7 +7,7 @@ import { Server } from './server'; | |||
7 | export interface Decoration { | 7 | export interface Decoration { |
8 | range: lc.Range; | 8 | range: lc.Range; |
9 | tag: string; | 9 | tag: string; |
10 | id?: string; | 10 | bindingHash?: string; |
11 | } | 11 | } |
12 | 12 | ||
13 | // Based on this HSL-based color generator: https://gist.github.com/bendc/76c48ce53299e6078a76 | 13 | // Based on this HSL-based color generator: https://gist.github.com/bendc/76c48ce53299e6078a76 |
@@ -92,6 +92,7 @@ export class Highlighter { | |||
92 | 92 | ||
93 | const byTag: Map<string, vscode.Range[]> = new Map(); | 93 | const byTag: Map<string, vscode.Range[]> = new Map(); |
94 | const colorfulIdents: Map<string, vscode.Range[]> = new Map(); | 94 | const colorfulIdents: Map<string, vscode.Range[]> = new Map(); |
95 | const rainbowTime = Server.config.rainbowHighlightingOn; | ||
95 | 96 | ||
96 | for (const tag of this.decorations.keys()) { | 97 | for (const tag of this.decorations.keys()) { |
97 | byTag.set(tag, []); | 98 | byTag.set(tag, []); |
@@ -102,12 +103,12 @@ export class Highlighter { | |||
102 | continue; | 103 | continue; |
103 | } | 104 | } |
104 | 105 | ||
105 | if (d.id) { | 106 | if (rainbowTime && d.bindingHash) { |
106 | if (!colorfulIdents.has(d.id)) { | 107 | if (!colorfulIdents.has(d.bindingHash)) { |
107 | colorfulIdents.set(d.id, []); | 108 | colorfulIdents.set(d.bindingHash, []); |
108 | } | 109 | } |
109 | colorfulIdents | 110 | colorfulIdents |
110 | .get(d.id)! | 111 | .get(d.bindingHash)! |
111 | .push( | 112 | .push( |
112 | Server.client.protocol2CodeConverter.asRange(d.range) | 113 | Server.client.protocol2CodeConverter.asRange(d.range) |
113 | ); | 114 | ); |