aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_lsp_server
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-08-06 12:34:28 +0100
committerAleksey Kladov <[email protected]>2019-08-06 13:28:31 +0100
commitdeea8f52d9803bb8a93d5dbd935970a20f07a51e (patch)
tree989408695c8c7347d4c9e907cf3f8feff7f2a982 /crates/ra_lsp_server
parent058c2daba1b81804d9f803e57c72f5702c124d9e (diff)
allow to exclude certain files and directories
Diffstat (limited to 'crates/ra_lsp_server')
-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
3 files changed, 29 insertions, 14 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