Skip to content

Commit 78817a3

Browse files
committed
Add "rust-analyzer.lens.enable"
1 parent 3d44525 commit 78817a3

File tree

3 files changed

+22
-6
lines changed

3 files changed

+22
-6
lines changed

crates/rust-analyzer/src/config.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ impl Default for LensConfig {
5050
}
5151

5252
impl LensConfig {
53+
pub const NO_LENS: LensConfig = Self { run: false, debug: false, impementations: false };
54+
5355
pub fn any(&self) -> bool {
5456
self.impementations || self.runnable()
5557
}
@@ -224,9 +226,16 @@ impl Config {
224226
set(value, "/completion/addCallParenthesis", &mut self.completion.add_call_parenthesis);
225227
set(value, "/completion/addCallArgumentSnippets", &mut self.completion.add_call_argument_snippets);
226228
set(value, "/callInfo/full", &mut self.call_info_full);
227-
set(value, "/lens/run", &mut self.lens.run);
228-
set(value, "/lens/debug", &mut self.lens.debug);
229-
set(value, "/lens/implementations", &mut self.lens.impementations);
229+
230+
let mut lens_enabled = true;
231+
set(value, "/lens/enable", &mut lens_enabled);
232+
if lens_enabled {
233+
set(value, "/lens/run", &mut self.lens.run);
234+
set(value, "/lens/debug", &mut self.lens.debug);
235+
set(value, "/lens/implementations", &mut self.lens.impementations);
236+
} else {
237+
self.lens = LensConfig::NO_LENS;
238+
}
230239

231240
log::info!("Config::update() = {:#?}", self);
232241

editors/code/package.json

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -444,18 +444,23 @@
444444
"default": {},
445445
"description": "Optional settings passed to the debug engine. Example:\n{ \"lldb\": { \"terminal\":\"external\"} }"
446446
},
447+
"rust-analyzer.lens.enable": {
448+
"description": "Whether to show CodeLens in Rust files.",
449+
"type": "boolean",
450+
"default": true
451+
},
447452
"rust-analyzer.lens.run": {
448-
"description": "Whether to show Run lens.",
453+
"markdownDescription": "Whether to show Run lens. Only applies when `#rust-analyzer.lens.enable#` is set.",
449454
"type": "boolean",
450455
"default": true
451456
},
452457
"rust-analyzer.lens.debug": {
453-
"description": "Whether to show Debug lens.",
458+
"markdownDescription": "Whether to show Debug lens. Only applies when `#rust-analyzer.lens.enable#` is set.",
454459
"type": "boolean",
455460
"default": true
456461
},
457462
"rust-analyzer.lens.implementations": {
458-
"description": "Whether to show Implementations lens.",
463+
"markdownDescription": "Whether to show Implementations lens. Only applies when `#rust-analyzer.lens.enable#` is set.",
459464
"type": "boolean",
460465
"default": true
461466
}

editors/code/src/config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export class Config {
1616
"files",
1717
"highlighting",
1818
"updates.channel",
19+
"lens.enable",
1920
"lens.run",
2021
"lens.debug",
2122
"lens.implementations",
@@ -125,6 +126,7 @@ export class Config {
125126

126127
get lens() {
127128
return {
129+
enable: this.get<boolean>("lens.enable"),
128130
run: this.get<boolean>("lens.run"),
129131
debug: this.get<boolean>("lens.debug"),
130132
implementations: this.get<boolean>("lens.implementations"),

0 commit comments

Comments
 (0)