Skip to content

Commit

Permalink
Use the correct language ID for (Java|Type)Script
Browse files Browse the repository at this point in the history
  • Loading branch information
hovsater committed Jan 8, 2022
1 parent 05e5520 commit b8eca75
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 17 deletions.
8 changes: 2 additions & 6 deletions helix-term/src/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -358,12 +358,8 @@ impl Application {

// trigger textDocument/didOpen for docs that are already open
for doc in docs {
// TODO: extract and share with editor.open
let language_id = doc
.language()
.and_then(|s| s.split('.').last()) // source.rust
.map(ToOwned::to_owned)
.unwrap_or_default();
let language_id =
doc.language().map(ToOwned::to_owned).unwrap_or_default();

tokio::spawn(language_server.text_document_did_open(
doc.url().unwrap(),
Expand Down
5 changes: 1 addition & 4 deletions helix-term/src/ui/completion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,10 +296,7 @@ impl Component for Completion {
// option.documentation

let (view, doc) = current!(cx.editor);
let language = doc
.language()
.and_then(|scope| scope.strip_prefix("source."))
.unwrap_or("");
let language = doc.language().unwrap_or("");
let text = doc.text().slice(..);
let cursor_pos = doc.selection(view.id).primary().cursor(text);
let coords = helix_core::visual_coords_at_pos(text, cursor_pos, doc.tab_width());
Expand Down
2 changes: 1 addition & 1 deletion helix-view/src/document.rs
Original file line number Diff line number Diff line change
Expand Up @@ -841,7 +841,7 @@ impl Document {
pub fn language(&self) -> Option<&str> {
self.language
.as_ref()
.map(|language| language.scope.as_str())
.map(|language| language.language_id.as_str())
}

/// Corresponding [`LanguageConfiguration`].
Expand Down
6 changes: 1 addition & 5 deletions helix-view/src/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,11 +307,7 @@ impl Editor {
if let Some(language_server) = doc.language_server() {
tokio::spawn(language_server.text_document_did_close(doc.identifier()));
}
let language_id = doc
.language()
.and_then(|s| s.split('.').last()) // source.rust
.map(ToOwned::to_owned)
.unwrap_or_default();
let language_id = doc.language().map(ToOwned::to_owned).unwrap_or_default();

// TODO: this now races with on_init code if the init happens too quickly
tokio::spawn(language_server.text_document_did_open(
Expand Down
3 changes: 2 additions & 1 deletion languages.toml
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@ language-server = { command = "typescript-language-server", args = ["--stdio"] }
indent = { tab-width = 2, unit = " " }

[[language]]
name = "tsx"
name = "typescriptreact"
tree-sitter-library = "tsx"
scope = "source.tsx"
injection-regex = "^(tsx)$" # |typescript
file-types = ["tsx"]
Expand Down
File renamed without changes.

0 comments on commit b8eca75

Please # to comment.