mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-21 23:01:05 +00:00
feat: more language support in highlighting (#22)
This commit is contained in:
parent
22b1fa998d
commit
011154abcb
4 changed files with 17 additions and 3 deletions
12
Cargo.lock
generated
12
Cargo.lock
generated
|
|
@ -272,6 +272,7 @@ dependencies = [
|
|||
"tracing",
|
||||
"trash",
|
||||
"unicode-width",
|
||||
"yazi-prebuild",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -2026,6 +2027,17 @@ dependencies = [
|
|||
"linked-hash-map",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "yazi-prebuild"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "81ddff73fa26e54bd54c652fda6c42ef86519b71f09265ef358a061f7bb92c8e"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"syntect",
|
||||
"walkdir",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zune-inflate"
|
||||
version = "0.2.54"
|
||||
|
|
|
|||
|
|
@ -25,3 +25,4 @@ tokio = { version = "^1", features = [ "parking_lot", "macros", "rt-mult
|
|||
tracing = "^0"
|
||||
trash = "^3"
|
||||
unicode-width = "^0"
|
||||
yazi-prebuild = "^0"
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ use anyhow::{anyhow, bail, Result};
|
|||
use config::{PREVIEW, THEME};
|
||||
use ratatui::prelude::Rect;
|
||||
use shared::{tty_size, MimeKind};
|
||||
use syntect::{easy::HighlightFile, highlighting::{Theme, ThemeSet}, parsing::SyntaxSet, util::as_24_bit_terminal_escaped};
|
||||
use syntect::{dumps::from_uncompressed_data, easy::HighlightFile, highlighting::{Theme, ThemeSet}, parsing::SyntaxSet, util::as_24_bit_terminal_escaped};
|
||||
use tokio::{fs, task::JoinHandle};
|
||||
|
||||
use super::{ALL_RATIO, CURRENT_RATIO, PARENT_RATIO, PREVIEW_BORDER, PREVIEW_MARGIN, PREVIEW_RATIO};
|
||||
|
|
@ -157,7 +157,8 @@ impl Preview {
|
|||
|
||||
pub async fn highlight(path: &Path, incr: Arc<AtomicUsize>) -> Result<String> {
|
||||
let tick = incr.load(Ordering::Relaxed);
|
||||
let syntax = SYNTECT_SYNTAX.get_or_init(|| SyntaxSet::load_defaults_newlines());
|
||||
let syntax =
|
||||
SYNTECT_SYNTAX.get_or_init(|| from_uncompressed_data(yazi_prebuild::syntaxes()).unwrap());
|
||||
let theme = SYNTECT_THEME.get_or_init(|| {
|
||||
let from_file = || -> Result<Theme> {
|
||||
let file = File::open(&THEME.preview.syntect_theme)?;
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
{"flagWords":[],"words":["Punct","KEYMAP","splitn","crossterm","YAZI","unar","peekable","ratatui","syntect","pbpaste","pbcopy","ffmpegthumbnailer","oneshot","Posix","Lsar","XADDOS","zoxide","cands","Deque","precache","imageops","IFBLK","IFCHR","IFDIR","IFIFO","IFLNK","IFMT","IFSOCK","IRGRP","IROTH","IRUSR","ISGID","ISUID","ISVTX","IWGRP","IWOTH","IWUSR","IXGRP","IXOTH","IXUSR","libc","winsize","TIOCGWINSZ","xpixel","ypixel","ioerr","appender","Catppuccin","macchiato","gitmodules","Dotfiles","bashprofile","vimrc","flac","webp","exiftool","mediainfo","ripgrep","nvim","indexmap","indexmap","unwatch","canonicalize","serde","fsevent","Ueberzug","iterm","wezterm","sixel","chafa","ueberzugpp","️ Überzug","️ Überzug","Konsole","Alacritty","Überzug","pkgs","paru","unarchiver","pdftoppm","poppler"],"version":"0.2","language":"en"}
|
||||
{"words":["Punct","KEYMAP","splitn","crossterm","YAZI","unar","peekable","ratatui","syntect","pbpaste","pbcopy","ffmpegthumbnailer","oneshot","Posix","Lsar","XADDOS","zoxide","cands","Deque","precache","imageops","IFBLK","IFCHR","IFDIR","IFIFO","IFLNK","IFMT","IFSOCK","IRGRP","IROTH","IRUSR","ISGID","ISUID","ISVTX","IWGRP","IWOTH","IWUSR","IXGRP","IXOTH","IXUSR","libc","winsize","TIOCGWINSZ","xpixel","ypixel","ioerr","appender","Catppuccin","macchiato","gitmodules","Dotfiles","bashprofile","vimrc","flac","webp","exiftool","mediainfo","ripgrep","nvim","indexmap","indexmap","unwatch","canonicalize","serde","fsevent","Ueberzug","iterm","wezterm","sixel","chafa","ueberzugpp","️ Überzug","️ Überzug","Konsole","Alacritty","Überzug","pkgs","paru","unarchiver","pdftoppm","poppler","prebuild"],"language":"en","version":"0.2","flagWords":[]}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue