feat: bump typstyle to v0.13.4 and add config for hard wrap (#1737)
Some checks failed
tinymist::gh_pages / build-gh-pages (push) Has been cancelled
tinymist::ci / Duplicate Actions Detection (push) Has been cancelled
tinymist::ci / Check Clippy, Formatting, Completion, Documentation, and Tests (Linux) (push) Has been cancelled
tinymist::ci / Check Minimum Rust version and Tests (Windows) (push) Has been cancelled
tinymist::ci / prepare-build (push) Has been cancelled
tinymist::ci / E2E Tests (darwin-arm64 on macos-latest) (push) Has been cancelled
tinymist::ci / E2E Tests (linux-x64 on ubuntu-22.04) (push) Has been cancelled
tinymist::ci / E2E Tests (linux-x64 on ubuntu-latest) (push) Has been cancelled
tinymist::ci / E2E Tests (win32-x64 on windows-2019) (push) Has been cancelled
tinymist::ci / E2E Tests (win32-x64 on windows-latest) (push) Has been cancelled
tinymist::ci / build-binary (push) Has been cancelled
tinymist::ci / build-vsc-assets (push) Has been cancelled
tinymist::ci / build-vscode (push) Has been cancelled
tinymist::ci / build-vscode-others (push) Has been cancelled
tinymist::ci / publish-vscode (push) Has been cancelled

This commit is contained in:
Wenzhuo Liu 2025-05-29 00:00:25 +08:00 committed by GitHub
parent b46b341d90
commit 39368da55f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 42 additions and 9 deletions

7
Cargo.lock generated
View file

@ -5140,15 +5140,18 @@ dependencies = [
[[package]]
name = "typstyle-core"
version = "0.13.3"
version = "0.13.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "64fafddba8b7f41ed38f1f1533443d93b49bb7b5960cd8b24012a15780e8f925"
checksum = "fc8ecc7ad0df59098d1d761bc6e18237abb7a01ae3828bace26c33783f570a85"
dependencies = [
"ecow",
"itertools 0.14.0",
"pretty",
"rustc-hash 2.1.1",
"smallvec",
"thiserror 2.0.12",
"typst-syntax",
"unicode-width 0.1.14",
]
[[package]]

View file

@ -156,7 +156,7 @@ typst-eval = "0.13.1"
typst-assets = "0.13.1"
typstfmt = { git = "https://github.com/Myriad-Dreamin/typstfmt", tag = "v0.13.1" }
typst-ansi-hl = "0.4.0"
typstyle-core = { version = "=0.13.3", default-features = false }
typstyle-core = { version = "=0.13.9", default-features = false }
# LSP
crossbeam-channel = "0.5.12"

View file

@ -119,7 +119,8 @@ pub struct Config {
pub formatter_print_width: Option<u32>,
/// Sets the indent size (using space) for the formatter.
pub formatter_indent_size: Option<u32>,
/// Sets the hard line wrapping mode for the formatter.
pub formatter_prose_wrap: Option<bool>,
/// The warnings during configuration update.
pub warnings: Vec<CowStr>,
}
@ -321,6 +322,7 @@ impl Config {
assign_config!(formatter_mode := "formatterMode"?: FormatterMode);
assign_config!(formatter_print_width := "formatterPrintWidth"?: Option<u32>);
assign_config!(formatter_indent_size := "formatterIndentSize"?: Option<u32>);
assign_config!(formatter_prose_wrap := "formatterProseWrap"?: Option<bool>);
assign_config!(output_path := "outputPath"?: PathPattern);
assign_config!(preview := "preview"?: PreviewFeat);
assign_config!(lint := "lint"?: LintFeat);
@ -469,17 +471,22 @@ impl Config {
pub fn formatter(&self) -> FormatUserConfig {
let formatter_print_width = self.formatter_print_width.unwrap_or(120) as usize;
let formatter_indent_size = self.formatter_indent_size.unwrap_or(2) as usize;
let formatter_line_wrap = self.formatter_prose_wrap.unwrap_or(false);
FormatUserConfig {
config: match self.formatter_mode {
FormatterMode::Typstyle => FormatterConfig::Typstyle(Box::new(
typstyle_core::Config::default()
.with_width(formatter_print_width)
.with_tab_spaces(formatter_indent_size),
)),
FormatterMode::Typstyle => {
FormatterConfig::Typstyle(Box::new(typstyle_core::Config {
tab_spaces: formatter_indent_size,
max_width: formatter_print_width,
wrap_text: formatter_line_wrap,
..typstyle_core::Config::default()
}))
}
FormatterMode::Typstfmt => FormatterConfig::Typstfmt(Box::new(typstfmt::Config {
max_line_length: formatter_print_width,
indent_space: formatter_indent_size,
line_wrap: formatter_line_wrap,
..typstfmt::Config::default()
})),
FormatterMode::Disable => FormatterConfig::Disable,

View file

@ -9,6 +9,7 @@ The changelog lines unspecified with authors are all written by the @Myriad-Drea
## v0.13.14 - [2025-05-31]
* Bumped MSRV to v1.85 in https://github.com/Myriad-Dreamin/tinymist/pull/1683
* Bumped typstyle from 0.13.3 to v0.13.9. This version includes few significant changes. For more details, see https://enter-tainer.github.io/typstyle/changelog/#v0139---2025-05-25
## v0.13.12 - [2025-04-30]

View file

@ -69,6 +69,7 @@ Enable or disable semantic tokens (LSP syntax highlighting)
Enable or disable lint checks. Note: restarting the editor is required to change this setting.
- **Type**: `boolean`
- **Default**: `false`
## `tinymist.lint.when`
@ -179,6 +180,13 @@ Sets the indent size (using space) for the formatter.
- **Type**: `number`
- **Default**: `2`
## `tinymist.formatterProseWrap`
Controls how the formatter handles prose line wrapping. Prose wrapping means inserting line breaks when a line exceeds the specified print width.
- **Type**: `boolean`
- **Default**: `false`
## `tinymist.showExportFileIn`
Configures way of opening exported files, e.g. inside of editor tabs or using system application.

View file

@ -490,6 +490,12 @@
"type": "number",
"default": 2
},
"tinymist.formatterProseWrap": {
"title": "%extension.tinymist.config.tinymist.formatterProseWrap.title%",
"markdownDescription": "%extension.tinymist.config.tinymist.formatterProseWrap.desc%",
"type": "boolean",
"default": false
},
"tinymist.showExportFileIn": {
"title": "%extension.tinymist.config.tinymist.showExportFileIn.title%",
"markdownDescription": "%extension.tinymist.config.tinymist.showExportFileIn.desc%",

View file

@ -1231,6 +1231,14 @@ zh = "格式化工具缩进长度"
en = "Sets the indent size (using space) for the formatter."
zh = "设置格式化工具的缩进长度(使用空格)。"
[extension.tinymist.config.tinymist.formatterProseWrap.title]
en = "Prose Wrapping Control"
zh = "文本换行控制"
[extension.tinymist.config.tinymist.formatterProseWrap.desc]
en = "Controls how the formatter handles prose line wrapping. If enabled, the formatter will insert hard line breaks at the specified print width. If disabled, the formatter keeps the original line breaks and spaces."
zh = "控制格式化程序如何处理文本换行。如果启用,格式化程序将在指定的打印宽度处插入换行符。如果禁用,格式化程序将保留原始换行符和空格。"
[extension.tinymist.config.tinymist.showExportFileIn.title]
en = "Show Export File In"
zh = "在哪里显示导出文件"