|
|
@ -180,7 +180,7 @@ pub struct Document {
|
|
|
|
pub(crate) modified_since_accessed: bool,
|
|
|
|
pub(crate) modified_since_accessed: bool,
|
|
|
|
|
|
|
|
|
|
|
|
diagnostics: Vec<Diagnostic>,
|
|
|
|
diagnostics: Vec<Diagnostic>,
|
|
|
|
language_servers: Vec<Arc<helix_lsp::Client>>,
|
|
|
|
pub(crate) language_servers: HashMap<LanguageServerName, Arc<Client>>,
|
|
|
|
|
|
|
|
|
|
|
|
diff_handle: Option<DiffHandle>,
|
|
|
|
diff_handle: Option<DiffHandle>,
|
|
|
|
version_control_head: Option<Arc<ArcSwap<Box<str>>>>,
|
|
|
|
version_control_head: Option<Arc<ArcSwap<Box<str>>>>,
|
|
|
@ -580,7 +580,7 @@ where
|
|
|
|
*mut_ref = f(mem::take(mut_ref));
|
|
|
|
*mut_ref = f(mem::take(mut_ref));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
use helix_lsp::{lsp, Client, OffsetEncoding};
|
|
|
|
use helix_lsp::{lsp, Client, LanguageServerName, OffsetEncoding};
|
|
|
|
use url::Url;
|
|
|
|
use url::Url;
|
|
|
|
|
|
|
|
|
|
|
|
impl Document {
|
|
|
|
impl Document {
|
|
|
@ -616,7 +616,7 @@ impl Document {
|
|
|
|
last_saved_time: SystemTime::now(),
|
|
|
|
last_saved_time: SystemTime::now(),
|
|
|
|
last_saved_revision: 0,
|
|
|
|
last_saved_revision: 0,
|
|
|
|
modified_since_accessed: false,
|
|
|
|
modified_since_accessed: false,
|
|
|
|
language_servers: Vec::new(),
|
|
|
|
language_servers: HashMap::new(),
|
|
|
|
diff_handle: None,
|
|
|
|
diff_handle: None,
|
|
|
|
config,
|
|
|
|
config,
|
|
|
|
version_control_head: None,
|
|
|
|
version_control_head: None,
|
|
|
@ -850,7 +850,7 @@ impl Document {
|
|
|
|
text: text.clone(),
|
|
|
|
text: text.clone(),
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
for language_server in language_servers {
|
|
|
|
for (_, language_server) in language_servers {
|
|
|
|
if !language_server.is_initialized() {
|
|
|
|
if !language_server.is_initialized() {
|
|
|
|
return Ok(event);
|
|
|
|
return Ok(event);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1006,11 +1006,6 @@ impl Document {
|
|
|
|
Ok(())
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Set the LSP.
|
|
|
|
|
|
|
|
pub fn set_language_servers(&mut self, language_servers: Vec<Arc<helix_lsp::Client>>) {
|
|
|
|
|
|
|
|
self.language_servers = language_servers;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Select text within the [`Document`].
|
|
|
|
/// Select text within the [`Document`].
|
|
|
|
pub fn set_selection(&mut self, view_id: ViewId, selection: Selection) {
|
|
|
|
pub fn set_selection(&mut self, view_id: ViewId, selection: Selection) {
|
|
|
|
// TODO: use a transaction?
|
|
|
|
// TODO: use a transaction?
|
|
|
@ -1437,16 +1432,17 @@ impl Document {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub fn language_servers(&self) -> impl Iterator<Item = &helix_lsp::Client> {
|
|
|
|
pub fn language_servers(&self) -> impl Iterator<Item = &helix_lsp::Client> {
|
|
|
|
self.language_servers
|
|
|
|
self.language_servers.values().filter_map(|l| {
|
|
|
|
.iter()
|
|
|
|
if l.is_initialized() {
|
|
|
|
.filter_map(|l| if l.is_initialized() { Some(&**l) } else { None })
|
|
|
|
Some(&**l)
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
None
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub fn remove_language_server_by_name(&mut self, name: &str) -> Option<Arc<Client>> {
|
|
|
|
pub fn remove_language_server_by_name(&mut self, name: &str) -> Option<Arc<Client>> {
|
|
|
|
match self.language_servers.iter().position(|l| l.name() == name) {
|
|
|
|
self.language_servers.remove(name)
|
|
|
|
Some(index) => Some(self.language_servers.remove(index)),
|
|
|
|
|
|
|
|
None => None,
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// TODO filter also based on LSP capabilities?
|
|
|
|
// TODO filter also based on LSP capabilities?
|
|
|
@ -1454,11 +1450,14 @@ impl Document {
|
|
|
|
&self,
|
|
|
|
&self,
|
|
|
|
feature: LanguageServerFeature,
|
|
|
|
feature: LanguageServerFeature,
|
|
|
|
) -> impl Iterator<Item = &helix_lsp::Client> {
|
|
|
|
) -> impl Iterator<Item = &helix_lsp::Client> {
|
|
|
|
self.language_servers().filter(move |server| {
|
|
|
|
self.language_config().into_iter().flat_map(move |config| {
|
|
|
|
self.language_config()
|
|
|
|
config.language_servers.iter().filter_map(move |features| {
|
|
|
|
.and_then(|config| config.language_servers.get(server.name()))
|
|
|
|
let ls = &**self.language_servers.get(&features.name)?;
|
|
|
|
.map_or(false, |server_features| {
|
|
|
|
if ls.is_initialized() && features.has_feature(feature) {
|
|
|
|
server_features.has_feature(feature)
|
|
|
|
Some(ls)
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
None
|
|
|
|
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1610,7 +1609,10 @@ impl Document {
|
|
|
|
.find(|ls| ls.id() == d.language_server_id)
|
|
|
|
.find(|ls| ls.id() == d.language_server_id)
|
|
|
|
.and_then(|ls| {
|
|
|
|
.and_then(|ls| {
|
|
|
|
let config = self.language_config()?;
|
|
|
|
let config = self.language_config()?;
|
|
|
|
let features = config.language_servers.get(ls.name())?;
|
|
|
|
let features = config
|
|
|
|
|
|
|
|
.language_servers
|
|
|
|
|
|
|
|
.iter()
|
|
|
|
|
|
|
|
.find(|features| features.name == ls.name())?;
|
|
|
|
Some(features.has_feature(LanguageServerFeature::Diagnostics))
|
|
|
|
Some(features.has_feature(LanguageServerFeature::Diagnostics))
|
|
|
|
})
|
|
|
|
})
|
|
|
|
== Some(true)
|
|
|
|
== Some(true)
|
|
|
|