diff options
| author | Gabriel Wu <qqbbnease1004@126.com> | 2023-05-30 16:46:56 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-05-30 10:46:56 +0200 |
| commit | 87ee97ae5e4f557034bad98e5aec770f5c5a0f35 (patch) | |
| tree | 777402dbc3cffbf947b06dbe3949d179f782ef65 /library/src/text | |
| parent | 47f81f0da57fb36214d2db19e425f9d73309e10a (diff) | |
Support syntax highlighting for more languages (#771)
Co-authored-by: Laurenz <laurmaedje@gmail.com>
Diffstat (limited to 'library/src/text')
| -rw-r--r-- | library/src/text/raw.rs | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/library/src/text/raw.rs b/library/src/text/raw.rs index 5929c04c..75e8ddc7 100644 --- a/library/src/text/raw.rs +++ b/library/src/text/raw.rs @@ -313,8 +313,33 @@ fn to_syn(RgbaColor { r, g, b, a }: RgbaColor) -> synt::Color { } /// The syntect syntax definitions. -static SYNTAXES: Lazy<syntect::parsing::SyntaxSet> = - Lazy::new(syntect::parsing::SyntaxSet::load_defaults_nonewlines); +/// +/// Code for syntax set generation is below. The `syntaxes` directory is from +/// <https://github.com/sharkdp/bat/tree/master/assets/syntaxes> +/// +/// ```ignore +/// fn main() { +/// let mut builder = syntect::parsing::SyntaxSet::load_defaults_nonewlines().into_builder(); +/// builder.add_from_folder("syntaxes/02_Extra", false).unwrap(); +/// syntect::dumps::dump_to_file(&builder.build(), "syntect.bin").unwrap(); +/// } +/// ``` +/// +/// The following syntaxes are disabled due to compatibility issues: +/// ```text +/// syntaxes/02_Extra/Assembly (ARM).sublime-syntax +/// syntaxes/02_Extra/Elixir/Regular Expressions (Elixir).sublime-syntax +/// syntaxes/02_Extra/JavaScript (Babel).sublime-syntax +/// syntaxes/02_Extra/LiveScript.sublime-syntax +/// syntaxes/02_Extra/PowerShell.sublime-syntax +/// syntaxes/02_Extra/SCSS_Sass/Syntaxes/Sass.sublime-syntax +/// syntaxes/02_Extra/SLS/SLS.sublime-syntax +/// syntaxes/02_Extra/VimHelp.sublime-syntax +/// syntaxes/02_Extra/cmd-help/syntaxes/cmd-help.sublime-syntax +/// ``` +static SYNTAXES: Lazy<syntect::parsing::SyntaxSet> = Lazy::new(|| { + syntect::dumps::from_binary(include_bytes!("../../../assets/data/syntect.bin")) +}); /// The default theme used for syntax highlighting. pub static THEME: Lazy<synt::Theme> = Lazy::new(|| synt::Theme { |
