mirror of
https://github.com/zed-industries/zed.git
synced 2024-12-24 17:28:40 +00:00
Implement missing prettier_server clear method
This commit is contained in:
parent
06cac18d78
commit
b687270207
1 changed files with 20 additions and 9 deletions
|
@ -209,7 +209,7 @@ impl Prettier {
|
|||
})
|
||||
});
|
||||
let tab_width = Some(language_settings.tab_size.get());
|
||||
PrettierFormatParams {
|
||||
FormatParams {
|
||||
text: buffer.text(),
|
||||
options: FormatOptions {
|
||||
parser,
|
||||
|
@ -220,7 +220,7 @@ impl Prettier {
|
|||
});
|
||||
let response = self
|
||||
.server
|
||||
.request::<PrettierFormat>(params)
|
||||
.request::<Format>(params)
|
||||
.await
|
||||
.context("prettier format request")?;
|
||||
let diff_task = buffer.read_with(cx, |buffer, cx| buffer.diff(response.text, cx));
|
||||
|
@ -228,7 +228,10 @@ impl Prettier {
|
|||
}
|
||||
|
||||
pub async fn clear_cache(&self) -> anyhow::Result<()> {
|
||||
todo!()
|
||||
self.server
|
||||
.request::<ClearCache>(())
|
||||
.await
|
||||
.context("prettier clear cache")
|
||||
}
|
||||
|
||||
pub fn server(&self) -> &Arc<LanguageServer> {
|
||||
|
@ -284,11 +287,11 @@ async fn find_closest_prettier_dir(
|
|||
Ok(None)
|
||||
}
|
||||
|
||||
enum PrettierFormat {}
|
||||
enum Format {}
|
||||
|
||||
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
struct PrettierFormatParams {
|
||||
struct FormatParams {
|
||||
text: String,
|
||||
options: FormatOptions,
|
||||
}
|
||||
|
@ -304,12 +307,20 @@ struct FormatOptions {
|
|||
|
||||
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
struct PrettierFormatResult {
|
||||
struct FormatResult {
|
||||
text: String,
|
||||
}
|
||||
|
||||
impl lsp::request::Request for PrettierFormat {
|
||||
type Params = PrettierFormatParams;
|
||||
type Result = PrettierFormatResult;
|
||||
impl lsp::request::Request for Format {
|
||||
type Params = FormatParams;
|
||||
type Result = FormatResult;
|
||||
const METHOD: &'static str = "prettier/format";
|
||||
}
|
||||
|
||||
enum ClearCache {}
|
||||
|
||||
impl lsp::request::Request for ClearCache {
|
||||
type Params = ();
|
||||
type Result = ();
|
||||
const METHOD: &'static str = "prettier/clear_cache";
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue