summaryrefslogtreecommitdiff
path: root/helix-term
diff options
context:
space:
mode:
Diffstat (limited to 'helix-term')
-rw-r--r--helix-term/src/application.rs16
-rw-r--r--helix-term/src/commands.rs6
-rw-r--r--helix-term/src/ui/editor.rs3
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);