Expose doc.language_server as an accessor.

pull/11/head
Blaž Hrastnik 4 years ago
parent 5237084d98
commit e261f3c50d

@ -888,7 +888,7 @@ fn goto(cx: &mut Context, locations: Vec<lsp::Location>) {
pub fn goto_definition(cx: &mut Context) { pub fn goto_definition(cx: &mut Context) {
let doc = cx.doc(); let doc = cx.doc();
let language_server = match doc.language_server.as_ref() { let language_server = match doc.language_server() {
Some(language_server) => language_server, Some(language_server) => language_server,
None => return, None => return,
}; };
@ -904,7 +904,7 @@ pub fn goto_definition(cx: &mut Context) {
pub fn goto_type_definition(cx: &mut Context) { pub fn goto_type_definition(cx: &mut Context) {
let doc = cx.doc(); let doc = cx.doc();
let language_server = match doc.language_server.as_ref() { let language_server = match doc.language_server() {
Some(language_server) => language_server, Some(language_server) => language_server,
None => return, None => return,
}; };
@ -920,7 +920,7 @@ pub fn goto_type_definition(cx: &mut Context) {
pub fn goto_implementation(cx: &mut Context) { pub fn goto_implementation(cx: &mut Context) {
let doc = cx.doc(); let doc = cx.doc();
let language_server = match doc.language_server.as_ref() { let language_server = match doc.language_server() {
Some(language_server) => language_server, Some(language_server) => language_server,
None => return, None => return,
}; };
@ -936,7 +936,7 @@ pub fn goto_implementation(cx: &mut Context) {
pub fn goto_reference(cx: &mut Context) { pub fn goto_reference(cx: &mut Context) {
let doc = cx.doc(); let doc = cx.doc();
let language_server = match doc.language_server.as_ref() { let language_server = match doc.language_server() {
Some(language_server) => language_server, Some(language_server) => language_server,
None => return, None => return,
}; };
@ -1179,7 +1179,7 @@ pub fn format_selections(cx: &mut Context) {
.collect(); .collect();
for range in ranges { for range in ranges {
let language_server = match doc.language_server.as_ref() { let language_server = match doc.language_server() {
Some(language_server) => language_server, Some(language_server) => language_server,
None => return, None => return,
}; };
@ -1279,7 +1279,7 @@ pub fn save(cx: &mut Context) {
pub fn completion(cx: &mut Context) { pub fn completion(cx: &mut Context) {
let doc = cx.doc(); let doc = cx.doc();
let language_server = match doc.language_server.as_ref() { let language_server = match doc.language_server() {
Some(language_server) => language_server, Some(language_server) => language_server,
None => return, None => return,
}; };
@ -1378,7 +1378,7 @@ pub fn hover(cx: &mut Context) {
let doc = cx.doc(); let doc = cx.doc();
let language_server = match doc.language_server.as_ref() { let language_server = match doc.language_server() {
Some(language_server) => language_server, Some(language_server) => language_server,
None => return, None => return,
}; };

@ -40,7 +40,7 @@ pub struct Document {
version: i32, // should be usize? version: i32, // should be usize?
pub diagnostics: Vec<Diagnostic>, pub diagnostics: Vec<Diagnostic>,
pub language_server: Option<Arc<helix_lsp::Client>>, language_server: Option<Arc<helix_lsp::Client>>,
} }
/// Like std::mem::replace() except it allows the replacement value to be mapped from the /// Like std::mem::replace() except it allows the replacement value to be mapped from the
@ -172,7 +172,7 @@ impl Document {
self.state.selection = selection; self.state.selection = selection;
} }
pub fn _apply(&mut self, transaction: &Transaction) -> bool { fn _apply(&mut self, transaction: &Transaction) -> bool {
let old_doc = self.text().clone(); let old_doc = self.text().clone();
let success = transaction.apply(&mut self.state); let success = transaction.apply(&mut self.state);
@ -288,6 +288,10 @@ impl Document {
self.version self.version
} }
pub fn language_server(&self) -> Option<&helix_lsp::Client> {
self.language_server.as_deref()
}
#[inline] #[inline]
pub fn path(&self) -> Option<&PathBuf> { pub fn path(&self) -> Option<&PathBuf> {
self.path.as_ref() self.path.as_ref()

Loading…
Cancel
Save