diff options
author | Nayeem Rahman <nayeemrmn99@gmail.com> | 2024-10-25 18:35:09 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-25 18:35:09 +0100 |
commit | 38c7af456518ac4fdbd36e3bfa731c38195bb773 (patch) | |
tree | 363228814b1b43cda6252e1adabdcf24e3989bb7 /cli/lsp | |
parent | 730331622ee17cf603447f4eb53631b9cfd7bef1 (diff) |
feat(lsp): "typescript.preferences.preferTypeOnlyAutoImports" setting (#26546)
Diffstat (limited to 'cli/lsp')
-rw-r--r-- | cli/lsp/config.rs | 5 | ||||
-rw-r--r-- | cli/lsp/tsc.rs | 7 |
2 files changed, 11 insertions, 1 deletions
diff --git a/cli/lsp/config.rs b/cli/lsp/config.rs index 74f3583d6..3ffc9e657 100644 --- a/cli/lsp/config.rs +++ b/cli/lsp/config.rs @@ -439,6 +439,8 @@ pub struct LanguagePreferences { pub use_aliases_for_renames: bool, #[serde(default)] pub quote_style: QuoteStyle, + #[serde(default)] + pub prefer_type_only_auto_imports: bool, } impl Default for LanguagePreferences { @@ -449,6 +451,7 @@ impl Default for LanguagePreferences { auto_import_file_exclude_patterns: vec![], use_aliases_for_renames: true, quote_style: Default::default(), + prefer_type_only_auto_imports: false, } } } @@ -2251,6 +2254,7 @@ mod tests { auto_import_file_exclude_patterns: vec![], use_aliases_for_renames: true, quote_style: QuoteStyle::Auto, + prefer_type_only_auto_imports: false, }, suggest: CompletionSettings { complete_function_calls: false, @@ -2296,6 +2300,7 @@ mod tests { auto_import_file_exclude_patterns: vec![], use_aliases_for_renames: true, quote_style: QuoteStyle::Auto, + prefer_type_only_auto_imports: false, }, suggest: CompletionSettings { complete_function_calls: false, diff --git a/cli/lsp/tsc.rs b/cli/lsp/tsc.rs index 0bc7d1600..0f31d7dd3 100644 --- a/cli/lsp/tsc.rs +++ b/cli/lsp/tsc.rs @@ -4952,6 +4952,8 @@ pub struct UserPreferences { pub auto_import_file_exclude_patterns: Option<Vec<String>>, #[serde(skip_serializing_if = "Option::is_none")] pub interactive_inlay_hints: Option<bool>, + #[serde(skip_serializing_if = "Option::is_none")] + pub prefer_type_only_auto_imports: Option<bool>, } impl UserPreferences { @@ -5074,6 +5076,9 @@ impl UserPreferences { } else { Some(language_settings.preferences.quote_style) }, + prefer_type_only_auto_imports: Some( + language_settings.preferences.prefer_type_only_auto_imports, + ), ..base_preferences } } @@ -6215,7 +6220,7 @@ mod tests { let change = changes.text_changes.first().unwrap(); assert_eq!( change.new_text, - "import type { someLongVariable } from './b.ts'\n" + "import { someLongVariable } from './b.ts'\n" ); } |