Make language adapters able to require certain bundled formatters
This commit is contained in:
parent
4f956d71e2
commit
12ea12e4e7
11 changed files with 80 additions and 20 deletions
|
@ -227,6 +227,10 @@ impl CachedLspAdapter {
|
|||
) -> Option<CodeLabel> {
|
||||
self.adapter.label_for_symbol(name, kind, language).await
|
||||
}
|
||||
|
||||
pub fn enabled_formatters(&self) -> Vec<BundledFormatter> {
|
||||
self.adapter.enabled_formatters()
|
||||
}
|
||||
}
|
||||
|
||||
pub trait LspAdapterDelegate: Send + Sync {
|
||||
|
@ -333,6 +337,26 @@ pub trait LspAdapter: 'static + Send + Sync {
|
|||
async fn language_ids(&self) -> HashMap<String, String> {
|
||||
Default::default()
|
||||
}
|
||||
|
||||
// TODO kb enable this for
|
||||
// markdown somehow?
|
||||
// tailwind (needs a css plugin, there are 2 of them)
|
||||
fn enabled_formatters(&self) -> Vec<BundledFormatter> {
|
||||
Vec::new()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub enum BundledFormatter {
|
||||
Prettier { plugin_names: Vec<String> },
|
||||
}
|
||||
|
||||
impl BundledFormatter {
|
||||
pub fn prettier() -> Self {
|
||||
Self::Prettier {
|
||||
plugin_names: Vec::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
|
|
|
@ -47,7 +47,6 @@ pub struct LanguageSettings {
|
|||
pub show_wrap_guides: bool,
|
||||
pub wrap_guides: Vec<usize>,
|
||||
pub format_on_save: FormatOnSave,
|
||||
pub prettier: bool,
|
||||
pub remove_trailing_whitespace_on_save: bool,
|
||||
pub ensure_final_newline_on_save: bool,
|
||||
pub formatter: Formatter,
|
||||
|
@ -93,8 +92,6 @@ pub struct LanguageSettingsContent {
|
|||
#[serde(default)]
|
||||
pub format_on_save: Option<FormatOnSave>,
|
||||
#[serde(default)]
|
||||
pub prettier: Option<bool>,
|
||||
#[serde(default)]
|
||||
pub remove_trailing_whitespace_on_save: Option<bool>,
|
||||
#[serde(default)]
|
||||
pub ensure_final_newline_on_save: Option<bool>,
|
||||
|
@ -401,7 +398,6 @@ fn merge_settings(settings: &mut LanguageSettings, src: &LanguageSettingsContent
|
|||
);
|
||||
merge(&mut settings.formatter, src.formatter.clone());
|
||||
merge(&mut settings.format_on_save, src.format_on_save.clone());
|
||||
merge(&mut settings.prettier, src.prettier);
|
||||
merge(
|
||||
&mut settings.remove_trailing_whitespace_on_save,
|
||||
src.remove_trailing_whitespace_on_save,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue