Skip to content

Commit

Permalink
fix regression in the LSP
Browse files Browse the repository at this point in the history
  • Loading branch information
ematipico committed Feb 29, 2024
1 parent f032bc7 commit a173d95
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion crates/biome_lsp/src/handlers/text_document.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub(crate) async fn did_open(
let url = params.text_document.uri;
let version = params.text_document.version;
let content = params.text_document.text;
let language_hint = DocumentFileSource::from_extension(&params.text_document.language_id);
let language_hint = DocumentFileSource::from_language_id(&params.text_document.language_id);

let biome_path = session.file_path(&url)?;
let doc = Document::new(version, &content);
Expand Down
23 changes: 23 additions & 0 deletions crates/biome_service/src/file_handlers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,29 @@ impl DocumentFileSource {
}
}

/// Returns the language corresponding to this language ID
///
/// See the [microsoft spec]
/// for a list of language identifiers
///
/// [microsoft spec]: https://code.visualstudio.com/docs/languages/identifiers
pub fn from_language_id(s: &str) -> Self {
match s.to_lowercase().as_str() {
"javascript" => JsFileSource::js_module().into(),
"typescript" => JsFileSource::ts().into(),
"javascriptreact" => JsFileSource::jsx().into(),
"typescriptreact" => JsFileSource::tsx().into(),
"json" => JsonFileSource::json().into(),
"jsonc" => JsonFileSource::json().into(),
"astro" => JsFileSource::astro().into(),
"vue" => JsFileSource::vue().into(),
"svelte" => JsFileSource::svelte().into(),
// TODO: remove this when we are ready to handle CSS files
"css" => DocumentFileSource::Unknown,
_ => DocumentFileSource::Unknown,
}
}

pub fn from_known_filename(s: &str) -> Self {
if Self::KNOWN_FILES_AS_JSONC.binary_search(&s).is_ok() {
JsonFileSource::jsonc().into()
Expand Down

0 comments on commit a173d95

Please sign in to comment.