summaryrefslogtreecommitdiff
path: root/cli/lsp/language_server.rs
diff options
context:
space:
mode:
Diffstat (limited to 'cli/lsp/language_server.rs')
-rw-r--r--cli/lsp/language_server.rs33
1 files changed, 24 insertions, 9 deletions
diff --git a/cli/lsp/language_server.rs b/cli/lsp/language_server.rs
index 491e402ad..00f49b05d 100644
--- a/cli/lsp/language_server.rs
+++ b/cli/lsp/language_server.rs
@@ -70,6 +70,7 @@ pub struct StateSnapshot {
pub assets: Assets,
pub config: ConfigSnapshot,
pub documents: DocumentCache,
+ pub maybe_config_uri: Option<ModuleSpecifier>,
pub module_registries: registries::ModuleRegistry,
pub performance: Performance,
pub sources: Sources,
@@ -92,6 +93,9 @@ pub(crate) struct Inner {
module_registries: registries::ModuleRegistry,
/// The path to the module registries cache
module_registries_location: PathBuf,
+ /// An optional configuration file which has been specified in the client
+ /// options.
+ maybe_config_file: Option<ConfigFile>,
/// An optional URL which provides the location of a TypeScript configuration
/// file which will be used by the Deno LSP.
maybe_config_uri: Option<Url>,
@@ -138,6 +142,7 @@ impl Inner {
config,
diagnostics_server,
documents: Default::default(),
+ maybe_config_file: Default::default(),
maybe_config_uri: Default::default(),
maybe_import_map: Default::default(),
maybe_import_map_uri: Default::default(),
@@ -326,6 +331,7 @@ impl Inner {
LspError::internal_error()
})?,
documents: self.documents.clone(),
+ maybe_config_uri: self.maybe_config_uri.clone(),
module_registries: self.module_registries.clone(),
performance: self.performance.clone(),
sources: self.sources.clone(),
@@ -477,6 +483,7 @@ impl Inner {
};
let (value, maybe_ignored_options) = config_file.as_compiler_options()?;
tsconfig.merge(&value);
+ self.maybe_config_file = Some(config_file);
self.maybe_config_uri = Some(config_url);
if let Some(ignored_options) = maybe_ignored_options {
// TODO(@kitsonk) turn these into diagnostics that can be sent to the
@@ -2281,20 +2288,28 @@ impl Inner {
if !params.uris.is_empty() {
for identifier in &params.uris {
let specifier = self.url_map.normalize_url(&identifier.uri);
- sources::cache(&specifier, &self.maybe_import_map)
- .await
- .map_err(|err| {
- error!("{}", err);
- LspError::internal_error()
- })?;
- }
- } else {
- sources::cache(&referrer, &self.maybe_import_map)
+ sources::cache(
+ &specifier,
+ &self.maybe_import_map,
+ &self.maybe_config_file,
+ )
.await
.map_err(|err| {
error!("{}", err);
LspError::internal_error()
})?;
+ }
+ } else {
+ sources::cache(
+ &referrer,
+ &self.maybe_import_map,
+ &self.maybe_config_file,
+ )
+ .await
+ .map_err(|err| {
+ error!("{}", err);
+ LspError::internal_error()
+ })?;
}
// now that we have dependencies loaded, we need to re-analyze them and
// invalidate some diagnostics