lsp: Pass through language_id on didOpenTextDocument.

pull/8/head
Blaž Hrastnik 4 years ago
parent 143cfe13e0
commit eca2a73ad0

@ -244,11 +244,12 @@ impl Client {
uri: lsp::Url, uri: lsp::Url,
version: i32, version: i32,
doc: &Rope, doc: &Rope,
language_id: String,
) -> Result<()> { ) -> Result<()> {
self.notify::<lsp::notification::DidOpenTextDocument>(lsp::DidOpenTextDocumentParams { self.notify::<lsp::notification::DidOpenTextDocument>(lsp::DidOpenTextDocumentParams {
text_document: lsp::TextDocumentItem { text_document: lsp::TextDocumentItem {
uri, uri,
language_id: "rust".to_string(), // TODO: hardcoded for now language_id,
version, version,
text: String::from(doc), text: String::from(doc),
}, },

@ -1183,6 +1183,7 @@ pub fn completion(cx: &mut Context) {
let pos = helix_lsp::util::pos_to_lsp_pos(doc.text().slice(..), doc.selection().cursor()); let pos = helix_lsp::util::pos_to_lsp_pos(doc.text().slice(..), doc.selection().cursor());
// TODO: handle fails // TODO: handle fails
let res = smol::block_on(language_server.completion(doc.identifier(), pos)).unwrap_or_default(); let res = smol::block_on(language_server.completion(doc.identifier(), pos)).unwrap_or_default();
// TODO: if no completion, show some message or something // TODO: if no completion, show some message or something

@ -46,10 +46,17 @@ impl Editor {
if let Some(language_server) = language_server { if let Some(language_server) = language_server {
doc.set_language_server(Some(language_server.clone())); doc.set_language_server(Some(language_server.clone()));
let language_id = doc
.language()
.and_then(|s| s.split(".").last()) // source.rust
.map(ToOwned::to_owned)
.unwrap_or_default();
smol::block_on(language_server.text_document_did_open( smol::block_on(language_server.text_document_did_open(
doc.url().unwrap(), doc.url().unwrap(),
doc.version(), doc.version(),
doc.text(), doc.text(),
language_id,
)) ))
.unwrap(); .unwrap();
} }

Loading…
Cancel
Save