diff options
author | Blaž Hrastnik | 2020-12-25 08:20:09 +0000 |
---|---|---|
committer | Blaž Hrastnik | 2020-12-25 08:20:09 +0000 |
commit | 2ab069bb3fc815394cccca50378b62932f3146f5 (patch) | |
tree | ac0b3d13198d0a9c5b49a11d3c1f2555a30418b7 /helix-term/src | |
parent | cd16df19c1f951e1ef0c560ae5e084b18bd2c713 (diff) |
lsp: Work on syncing the state with the language server.
Diffstat (limited to 'helix-term/src')
-rw-r--r-- | helix-term/src/application.rs | 16 | ||||
-rw-r--r-- | helix-term/src/commands.rs | 6 | ||||
-rw-r--r-- | helix-term/src/ui/editor.rs | 3 |
3 files changed, 19 insertions, 6 deletions
diff --git a/helix-term/src/application.rs b/helix-term/src/application.rs index 138f55c2..004c5c61 100644 --- a/helix-term/src/application.rs +++ b/helix-term/src/application.rs @@ -44,16 +44,23 @@ impl Application { let mut editor = Editor::new(); let size = terminal.size()?; + let language_servers = helix_lsp::Registry::new(); + let language_server = language_servers.get("rust", &executor).unwrap(); + if let Some(file) = args.values_of_t::<PathBuf>("files").unwrap().pop() { editor.open(file, (size.width, size.height))?; + + // TODO: do this everywhere + editor + .view_mut() + .unwrap() + .doc + .set_language_server(Some(language_server.clone())); } let mut compositor = Compositor::new(); compositor.push(Box::new(ui::EditorView::new())); - let language_servers = helix_lsp::Registry::new(); - let language_server = language_servers.get("rust", &executor).unwrap(); - let mut app = Self { editor, terminal, @@ -90,8 +97,9 @@ impl Application { pub async fn event_loop(&mut self) { let mut reader = EventStream::new(); + let doc = &self.editor.view().unwrap().doc; self.language_server - .text_document_did_open(&self.editor.view().unwrap().doc) + .text_document_did_open(doc.url().unwrap(), doc.version, doc.text()) .await .unwrap(); diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index 862cf312..59490864 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -841,9 +841,13 @@ pub fn completion(cx: &mut Context) { use std::time::Duration; // TODO: blocking here is not ideal + let pos = helix_lsp::util::pos_to_lsp_pos( + &cx.view.doc.text().slice(..), + cx.view.doc.selection().cursor(), + ); let res = smol::block_on( language_server - .completion(&cx.view.doc) + .completion(cx.view.doc.identifier(), pos) .timeout(Duration::from_secs(2)), ) .expect("completion failed!") diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs index 25221922..629cb85c 100644 --- a/helix-term/src/ui/editor.rs +++ b/helix-term/src/ui/editor.rs @@ -41,7 +41,8 @@ impl EditorView { self.render_buffer(view, area, surface, theme); // clear with background color - surface.set_style(viewport, theme.get("ui.background")); + // TODO: this seems to prevent setting style later + // surface.set_style(viewport, theme.get("ui.background")); let area = Rect::new(0, viewport.height - 2, viewport.width, 1); self.render_statusline(view, area, surface, theme); |