pub struct Config<'a> { /* private fields */ }Expand description
Configuration for the diagnostic renderer
Implementations§
Source§impl<'a> Config<'a>
impl<'a> Config<'a>
Sourcepub fn with_cross_gap(self, enabled: bool) -> Self
pub fn with_cross_gap(self, enabled: bool) -> Self
Enable or disable cross gap rendering.
When enabled, vertical bars between labels are drawn with gaps for better visual clarity when labels overlap.
Default: depends on C library default
Sourcepub fn with_compact(self, enabled: bool) -> Self
pub fn with_compact(self, enabled: bool) -> Self
Enable or disable compact mode.
In compact mode, the diagnostic output is more condensed:
- Underlines and arrows may be merged onto the same line
- Only meaningful label arrows are shown
Works with underlines enabled or disabled.
Default: false
Sourcepub fn with_underlines(self, enabled: bool) -> Self
pub fn with_underlines(self, enabled: bool) -> Self
Enable or disable underlines for highlighted spans.
When enabled, spans are underlined with characters like ^^^.
When disabled, only label arrows are shown.
Works with both compact and non-compact modes.
Default: true
Sourcepub fn with_column_order(self, enabled: bool) -> Self
pub fn with_column_order(self, enabled: bool) -> Self
Enable or disable natural label ordering.
When disabled (default), labels are sorted to minimize line crossings:
- Inline labels appear first, ordered by reverse column position
- Multi-line labels follow, with tails before heads
When enabled, labels are simply sorted by column position.
Default: false (natural ordering enabled)
§Example
let config = Config::new().with_column_order(true); // Simple column orderSourcepub fn with_align_messages(self, enabled: bool) -> Self
pub fn with_align_messages(self, enabled: bool) -> Self
Enable or disable aligned label messages.
When enabled (default), label messages are aligned to the same column, producing a more structured appearance with longer arrows.
When disabled, messages are placed immediately after their arrows, creating more compact output.
Default: true (aligned)
§Example
let config = Config::new().with_align_messages(false); // Compact arrowsSourcepub fn with_multiline_arrows(self, enabled: bool) -> Self
pub fn with_multiline_arrows(self, enabled: bool) -> Self
Enable or disable multiline arrows for labels.
When enabled, labels that span multiple lines will have arrows drawn across all covered lines.
Default: true
Sourcepub fn with_tab_width(self, width: i32) -> Self
pub fn with_tab_width(self, width: i32) -> Self
Set the tab width for rendering.
Tab characters (\t) in source code are expanded to this many spaces.
Default: 4
§Example
let config = Config::new().with_tab_width(8); // 8-space tabsSourcepub fn with_limit_width(self, width: i32) -> Self
pub fn with_limit_width(self, width: i32) -> Self
Set the width limit for line wrapping.
Lines longer than this width will be truncated with an ellipsis.
Set to 0 for no limit (lines can be arbitrarily long).
Default: 0 (no limit)
§Example
let config = Config::new().with_limit_width(80); // Wrap at 80 columnsSourcepub fn with_ambi_width(self, width: i32) -> Self
pub fn with_ambi_width(self, width: i32) -> Self
Set the ambiguous character width.
Some Unicode characters have ambiguous width (e.g., East Asian characters). This setting determines their display width:
1- Treat as narrow (1 column)2- Treat as wide (2 columns)
Default: 1
§Example
let config = Config::new().with_ambi_width(2); // East Asian widthSourcepub fn with_label_attach(self, attach: LabelAttach) -> Self
pub fn with_label_attach(self, attach: LabelAttach) -> Self
Set where labels attach to spans.
Controls the default attachment point for all labels.
Individual labels can override this with Report::with_order.
Default: LabelAttach::Middle
Sourcepub fn with_index_type(self, index_type: IndexType) -> Self
pub fn with_index_type(self, index_type: IndexType) -> Self
Set the index type (character or byte).
Determines how span ranges are interpreted.
See IndexType for details.
Default: IndexType::Char
Sourcepub fn with_char_set_ascii(self) -> Self
pub fn with_char_set_ascii(self) -> Self
Set ASCII character set for rendering.
Uses ASCII characters (-, |, +, etc.) for box drawing.
This is compatible with all terminals and file formats.
§Example
Error: message
,-[ file.rs:1:1 ]
|
1 | code here
| ^^|^
| `--- label
---'Sourcepub fn with_char_set_unicode(self) -> Self
pub fn with_char_set_unicode(self) -> Self
Set Unicode character set for rendering.
Uses Unicode box-drawing characters (─, │, ┬, etc.) for prettier output. Requires a terminal that supports Unicode.
§Example
Error: message
╭─[ file.rs:1:1 ]
│
1 │ code here
│ ──┬─
│ ╰─── label
───╯Sourcepub fn with_char_set(self, char_set: &'a CharSet) -> Self
pub fn with_char_set(self, char_set: &'a CharSet) -> Self
Set a custom character set for rendering.
Allows fine-grained control over all box-drawing characters. The character set must outlive the config.
§Example
let custom = CharSet {
hbar: '=',
vbar: '!',
..CharSet::ascii()
};
let config = Config::new().with_char_set(&custom);Sourcepub fn with_color_default(self) -> Self
pub fn with_color_default(self) -> Self
Enable default ANSI colors.
Uses the built-in color scheme with standard ANSI escape codes:
- Errors in red
- Warnings in yellow
- Margins in blue
- etc.
This is appropriate for terminal output.
Sourcepub fn with_color_disabled(self) -> Self
pub fn with_color_disabled(self) -> Self
Disable color output.
All output will be plain text without ANSI escape codes. This is appropriate for file output or non-color terminals.
Default: colors are disabled
Sourcepub fn with_color<C>(self, color: &'a C) -> Selfwhere
C: Color,
pub fn with_color<C>(self, color: &'a C) -> Selfwhere
C: Color,
Set a custom color provider.