aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/ra_lsp_server/src/config.rs11
-rw-r--r--crates/ra_lsp_server/src/main_loop.rs8
-rw-r--r--crates/ra_lsp_server/src/world.rs24
-rw-r--r--docs/user/README.md3
-rw-r--r--editors/code/package.json5
-rw-r--r--editors/code/src/config.ts4
-rw-r--r--editors/code/src/server.ts3
7 files changed, 43 insertions, 15 deletions
diff --git a/crates/ra_lsp_server/src/config.rs b/crates/ra_lsp_server/src/config.rs
index a16cc292e..6dcdc695a 100644
--- a/crates/ra_lsp_server/src/config.rs
+++ b/crates/ra_lsp_server/src/config.rs
@@ -1,7 +1,7 @@
1use serde::{Deserialize, Deserializer}; 1use serde::{Deserialize, Deserializer};
2 2
3/// Client provided initialization options 3/// Client provided initialization options
4#[derive(Deserialize, Clone, Copy, Debug, PartialEq, Eq)] 4#[derive(Deserialize, Clone, Debug, PartialEq, Eq)]
5#[serde(rename_all = "camelCase", default)] 5#[serde(rename_all = "camelCase", default)]
6pub struct ServerConfig { 6pub struct ServerConfig {
7 /// Whether the client supports our custom highlighting publishing decorations. 7 /// Whether the client supports our custom highlighting publishing decorations.
@@ -18,12 +18,19 @@ pub struct ServerConfig {
18 #[serde(deserialize_with = "nullable_bool_true")] 18 #[serde(deserialize_with = "nullable_bool_true")]
19 pub show_workspace_loaded: bool, 19 pub show_workspace_loaded: bool,
20 20
21 pub exclude_globs: Vec<String>,
22
21 pub lru_capacity: Option<usize>, 23 pub lru_capacity: Option<usize>,
22} 24}
23 25
24impl Default for ServerConfig { 26impl Default for ServerConfig {
25 fn default() -> ServerConfig { 27 fn default() -> ServerConfig {
26 ServerConfig { publish_decorations: false, show_workspace_loaded: true, lru_capacity: None } 28 ServerConfig {
29 publish_decorations: false,
30 show_workspace_loaded: true,
31 exclude_globs: Vec::new(),
32 lru_capacity: None,
33 }
27 } 34 }
28} 35}
29 36
diff --git a/crates/ra_lsp_server/src/main_loop.rs b/crates/ra_lsp_server/src/main_loop.rs
index 8ab501828..9d540a87e 100644
--- a/crates/ra_lsp_server/src/main_loop.rs
+++ b/crates/ra_lsp_server/src/main_loop.rs
@@ -56,6 +56,7 @@ pub fn main_loop(
56 msg_receiver: &Receiver<RawMessage>, 56 msg_receiver: &Receiver<RawMessage>,
57 msg_sender: &Sender<RawMessage>, 57 msg_sender: &Sender<RawMessage>,
58) -> Result<()> { 58) -> Result<()> {
59 log::debug!("server_config: {:?}", config);
59 // FIXME: support dynamic workspace loading. 60 // FIXME: support dynamic workspace loading.
60 let workspaces = { 61 let workspaces = {
61 let ws_worker = workspace_loader(); 62 let ws_worker = workspace_loader();
@@ -77,11 +78,16 @@ pub fn main_loop(
77 } 78 }
78 loaded_workspaces 79 loaded_workspaces
79 }; 80 };
80 81 let globs = config
82 .exclude_globs
83 .iter()
84 .map(|glob| ra_vfs_glob::Glob::new(glob))
85 .collect::<std::result::Result<Vec<_>, _>>()?;
81 let mut state = WorldState::new( 86 let mut state = WorldState::new(
82 ws_roots, 87 ws_roots,
83 workspaces, 88 workspaces,
84 config.lru_capacity, 89 config.lru_capacity,
90 &globs,
85 Options { 91 Options {
86 publish_decorations: config.publish_decorations, 92 publish_decorations: config.publish_decorations,
87 show_workspace_loaded: config.show_workspace_loaded, 93 show_workspace_loaded: config.show_workspace_loaded,
diff --git a/crates/ra_lsp_server/src/world.rs b/crates/ra_lsp_server/src/world.rs
index a8aafe5cb..9990ef62e 100644
--- a/crates/ra_lsp_server/src/world.rs
+++ b/crates/ra_lsp_server/src/world.rs
@@ -10,7 +10,7 @@ use ra_ide_api::{
10 Analysis, AnalysisChange, AnalysisHost, CrateGraph, FileId, LibraryData, SourceRootId, 10 Analysis, AnalysisChange, AnalysisHost, CrateGraph, FileId, LibraryData, SourceRootId,
11}; 11};
12use ra_vfs::{RootEntry, Vfs, VfsChange, VfsFile, VfsRoot}; 12use ra_vfs::{RootEntry, Vfs, VfsChange, VfsFile, VfsRoot};
13use ra_vfs_glob::RustPackageFilterBuilder; 13use ra_vfs_glob::{Glob, RustPackageFilterBuilder};
14use relative_path::RelativePathBuf; 14use relative_path::RelativePathBuf;
15 15
16use crate::{ 16use crate::{
@@ -56,25 +56,27 @@ impl WorldState {
56 folder_roots: Vec<PathBuf>, 56 folder_roots: Vec<PathBuf>,
57 workspaces: Vec<ProjectWorkspace>, 57 workspaces: Vec<ProjectWorkspace>,
58 lru_capacity: Option<usize>, 58 lru_capacity: Option<usize>,
59 exclude_globs: &[Glob],
59 options: Options, 60 options: Options,
60 ) -> WorldState { 61 ) -> WorldState {
61 let mut change = AnalysisChange::new(); 62 let mut change = AnalysisChange::new();
62 63
63 let mut roots = Vec::new(); 64 let mut roots = Vec::new();
64 roots.extend(folder_roots.iter().map(|path| { 65 roots.extend(folder_roots.iter().map(|path| {
65 RootEntry::new( 66 let mut filter = RustPackageFilterBuilder::default().set_member(true);
66 path.clone(), 67 for glob in exclude_globs.iter() {
67 RustPackageFilterBuilder::default().set_member(true).into_vfs_filter(), 68 filter = filter.exclude(glob.clone());
68 ) 69 }
70 RootEntry::new(path.clone(), filter.into_vfs_filter())
69 })); 71 }));
70 for ws in workspaces.iter() { 72 for ws in workspaces.iter() {
71 roots.extend(ws.to_roots().into_iter().map(|pkg_root| { 73 roots.extend(ws.to_roots().into_iter().map(|pkg_root| {
72 RootEntry::new( 74 let mut filter =
73 pkg_root.path().clone(), 75 RustPackageFilterBuilder::default().set_member(pkg_root.is_member());
74 RustPackageFilterBuilder::default() 76 for glob in exclude_globs.iter() {
75 .set_member(pkg_root.is_member()) 77 filter = filter.exclude(glob.clone());
76 .into_vfs_filter(), 78 }
77 ) 79 RootEntry::new(pkg_root.path().clone(), filter.into_vfs_filter())
78 })); 80 }));
79 } 81 }
80 82
diff --git a/docs/user/README.md b/docs/user/README.md
index a5e17f604..7990d1d31 100644
--- a/docs/user/README.md
+++ b/docs/user/README.md
@@ -71,6 +71,9 @@ See https://github.com/microsoft/vscode/issues/72308[microsoft/vscode#72308] for
71* `rust-analyzer.raLspServerPath`: path to `ra_lsp_server` executable 71* `rust-analyzer.raLspServerPath`: path to `ra_lsp_server` executable
72* `rust-analyzer.enableCargoWatchOnStartup`: prompt to install & enable `cargo 72* `rust-analyzer.enableCargoWatchOnStartup`: prompt to install & enable `cargo
73 watch` for live error highlighting (note, this **does not** use rust-analyzer) 73 watch` for live error highlighting (note, this **does not** use rust-analyzer)
74* `rust-analyzer.excludeGlobs`: a list of glob-patterns for exclusion (see globset [docs](https://docs.rs/globset) for syntax).
75 Note: glob patterns are applied to all Cargo packages and a rooted at a package root.
76 This is not very intuitive and a limitation of a current implementation.
74* `rust-analyzer.cargo-watch.check-arguments`: cargo-watch check arguments. 77* `rust-analyzer.cargo-watch.check-arguments`: cargo-watch check arguments.
75 (e.g: `--features="shumway,pdf"` will run as `cargo watch -x "check --features="shumway,pdf""` ) 78 (e.g: `--features="shumway,pdf"` will run as `cargo watch -x "check --features="shumway,pdf""` )
76* `rust-analyzer.trace.server`: enables internal logging 79* `rust-analyzer.trace.server`: enables internal logging
diff --git a/editors/code/package.json b/editors/code/package.json
index 808dc5dc1..48ab886bf 100644
--- a/editors/code/package.json
+++ b/editors/code/package.json
@@ -197,6 +197,11 @@
197 ], 197 ],
198 "description": "Whether to run `cargo watch` on startup" 198 "description": "Whether to run `cargo watch` on startup"
199 }, 199 },
200 "rust-analyzer.excludeGlobs": {
201 "type": "array",
202 "default": "[]",
203 "description": "Paths to exclude from analysis"
204 },
200 "rust-analyzer.cargo-watch.arguments": { 205 "rust-analyzer.cargo-watch.arguments": {
201 "type": "string", 206 "type": "string",
202 "description": "`cargo-watch` arguments. (e.g: `--features=\"shumway,pdf\"` will run as `cargo watch -x \"check --features=\"shumway,pdf\"\"` )", 207 "description": "`cargo-watch` arguments. (e.g: `--features=\"shumway,pdf\"` will run as `cargo watch -x \"check --features=\"shumway,pdf\"\"` )",
diff --git a/editors/code/src/config.ts b/editors/code/src/config.ts
index 4d58a1a93..4df6b50ef 100644
--- a/editors/code/src/config.ts
+++ b/editors/code/src/config.ts
@@ -22,6 +22,7 @@ export class Config {
22 public showWorkspaceLoadedNotification = true; 22 public showWorkspaceLoadedNotification = true;
23 public lruCapacity: null | number = null; 23 public lruCapacity: null | number = null;
24 public displayInlayHints = true; 24 public displayInlayHints = true;
25 public excludeGlobs = [];
25 public cargoWatchOptions: CargoWatchOptions = { 26 public cargoWatchOptions: CargoWatchOptions = {
26 enableOnStartup: 'ask', 27 enableOnStartup: 'ask',
27 trace: 'off', 28 trace: 'off',
@@ -128,5 +129,8 @@ export class Config {
128 if (config.has('displayInlayHints')) { 129 if (config.has('displayInlayHints')) {
129 this.displayInlayHints = config.get('displayInlayHints') as boolean; 130 this.displayInlayHints = config.get('displayInlayHints') as boolean;
130 } 131 }
132 if (config.has('excludeGlobs')) {
133 this.excludeGlobs = config.get('excludeGlobs') || [];
134 }
131 } 135 }
132} 136}
diff --git a/editors/code/src/server.ts b/editors/code/src/server.ts
index 7029142fd..2b4c25c28 100644
--- a/editors/code/src/server.ts
+++ b/editors/code/src/server.ts
@@ -36,7 +36,8 @@ export class Server {
36 publishDecorations: true, 36 publishDecorations: true,
37 showWorkspaceLoaded: 37 showWorkspaceLoaded:
38 Server.config.showWorkspaceLoadedNotification, 38 Server.config.showWorkspaceLoadedNotification,
39 lruCapacity: Server.config.lruCapacity 39 lruCapacity: Server.config.lruCapacity,
40 excludeGlobs: Server.config.excludeGlobs
40 }, 41 },
41 traceOutputChannel 42 traceOutputChannel
42 }; 43 };