mirror of
https://github.com/Myriad-Dreamin/tinymist.git
synced 2025-08-03 17:58:17 +00:00
build: upgrade typstyle to v0.12.14 (#1260)
* build: upgrade typstyle to 0.12.14 * typstyle version * build: update cargo.lock --------- Co-authored-by: ParaN3xus <paran3xus007@gmail.com>
This commit is contained in:
parent
39bc123866
commit
a778c8c10c
4 changed files with 9 additions and 33 deletions
|
@ -406,7 +406,7 @@ impl Config {
|
|||
FormatUserConfig {
|
||||
config: match self.formatter_mode {
|
||||
FormatterMode::Typstyle => FormatterConfig::Typstyle(Box::new(
|
||||
typstyle_core::PrinterConfig::new_with_width(formatter_print_width),
|
||||
typstyle_core::Config::default().with_width(formatter_print_width),
|
||||
)),
|
||||
FormatterMode::Typstfmt => FormatterConfig::Typstfmt(Box::new(typstfmt::Config {
|
||||
max_line_length: formatter_print_width,
|
||||
|
|
|
@ -9,43 +9,19 @@ use typst::syntax::Source;
|
|||
|
||||
use super::SyncTaskFactory;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub enum FormatterConfig {
|
||||
Typstyle(Box<typstyle_core::PrinterConfig>),
|
||||
Typstyle(Box<typstyle_core::Config>),
|
||||
Typstfmt(Box<typstfmt::Config>),
|
||||
Disable,
|
||||
}
|
||||
|
||||
impl FormatterConfig {
|
||||
/// The configuration structs doesn't implement `PartialEq`, so bad.
|
||||
pub fn eq(&self, other: &Self) -> bool {
|
||||
match (self, other) {
|
||||
(Self::Typstyle(a), Self::Typstyle(b)) => {
|
||||
a.tab_spaces == b.tab_spaces
|
||||
&& a.max_width == b.max_width
|
||||
&& a.chain_width_ratio == b.chain_width_ratio
|
||||
&& a.blank_lines_upper_bound == b.blank_lines_upper_bound
|
||||
}
|
||||
(Self::Typstfmt(a), Self::Typstfmt(b)) => a == b,
|
||||
(Self::Disable, Self::Disable) => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct FormatUserConfig {
|
||||
pub config: FormatterConfig,
|
||||
pub position_encoding: PositionEncoding,
|
||||
}
|
||||
|
||||
impl FormatUserConfig {
|
||||
/// The configuration structs doesn't implement `PartialEq`, so bad.
|
||||
pub fn eq(&self, other: &Self) -> bool {
|
||||
self.config.eq(&other.config) && self.position_encoding == other.position_encoding
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct FormatTask {
|
||||
factory: SyncTaskFactory<FormatUserConfig>,
|
||||
|
@ -67,8 +43,8 @@ impl FormatTask {
|
|||
just_future(async move {
|
||||
let formatted = match &c.config {
|
||||
FormatterConfig::Typstyle(config) => {
|
||||
typstyle_core::Typstyle::new_with_src(src.clone(), config.as_ref().clone())
|
||||
.pretty_print()
|
||||
typstyle_core::Typstyle::new(config.as_ref().clone())
|
||||
.format_source(&src)
|
||||
.ok()
|
||||
}
|
||||
FormatterConfig::Typstfmt(config) => Some(typstfmt::format(src.text(), **config)),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue