vtcode_config/defaults/
syntax_highlighting.rs

1use super::provider;
2
3const DEFAULT_MAX_FILE_SIZE_MB: usize = 10;
4const DEFAULT_HIGHLIGHT_TIMEOUT_MS: u64 = 5_000;
5const MIN_FILE_SIZE_MB: usize = 1;
6const MIN_HIGHLIGHT_TIMEOUT_MS: u64 = 100;
7
8/// Shared defaults for syntax highlighting configuration.
9pub struct SyntaxHighlightingDefaults;
10
11impl SyntaxHighlightingDefaults {
12    /// Whether syntax highlighting is enabled by default.
13    pub fn enabled() -> bool {
14        true
15    }
16
17    /// Whether theme caching is enabled by default.
18    pub fn cache_themes() -> bool {
19        true
20    }
21
22    /// Default syntax highlighting theme identifier.
23    pub fn theme() -> String {
24        provider::with_config_defaults(|defaults| defaults.syntax_theme())
25    }
26
27    /// Default maximum file size (in megabytes) that will be highlighted.
28    pub fn max_file_size_mb() -> usize {
29        DEFAULT_MAX_FILE_SIZE_MB
30    }
31
32    /// Default timeout (in milliseconds) for highlighting operations.
33    pub fn highlight_timeout_ms() -> u64 {
34        DEFAULT_HIGHLIGHT_TIMEOUT_MS
35    }
36
37    /// Minimum supported highlight timeout.
38    pub fn min_highlight_timeout_ms() -> u64 {
39        MIN_HIGHLIGHT_TIMEOUT_MS
40    }
41
42    /// Minimum supported highlighted file size.
43    pub fn min_file_size_mb() -> usize {
44        MIN_FILE_SIZE_MB
45    }
46
47    /// Default list of enabled languages.
48    pub fn enabled_languages() -> Vec<String> {
49        provider::with_config_defaults(|defaults| defaults.syntax_languages())
50    }
51}
52
53/// Serde helper returning the default enabled flag.
54pub fn enabled() -> bool {
55    SyntaxHighlightingDefaults::enabled()
56}
57
58/// Serde helper returning the default cache flag.
59pub fn cache_themes() -> bool {
60    SyntaxHighlightingDefaults::cache_themes()
61}
62
63/// Serde helper returning the default theme string.
64pub fn theme() -> String {
65    SyntaxHighlightingDefaults::theme()
66}
67
68/// Serde helper returning the default maximum file size.
69pub fn max_file_size_mb() -> usize {
70    SyntaxHighlightingDefaults::max_file_size_mb()
71}
72
73/// Serde helper returning the default highlight timeout.
74pub fn highlight_timeout_ms() -> u64 {
75    SyntaxHighlightingDefaults::highlight_timeout_ms()
76}
77
78/// Serde helper returning the default language list.
79pub fn enabled_languages() -> Vec<String> {
80    SyntaxHighlightingDefaults::enabled_languages()
81}