#1163·yazi

Add support for using mime-type as the fallback for highlighting

Author: mikavilpasCreated Jun 17, 2024Updated Jul 27, 2026
Labelsfeature

What system are you running Yazi on?

macOS

What terminal are you running Yazi in?

Wezterm

Did you try the latest code to see if this problem got fixed?

Tried, but the problem still

yazi --debug output

bash

Yazi
    Version: 0.2.5 (2a35d30 2024-06-17)
    Debug  : false
    OS     : macos-aarch64 (unix)

Ya
    Version: 0.2.5

Emulator
    Emulator.via_env: ("xterm-256color", "WezTerm")
    Emulator.via_csi: Ok(WezTerm)
    Emulator.detect : WezTerm

Adapter
    Adapter.matches: Iterm2

Desktop
    XDG_SESSION_TYPE: None
    WAYLAND_DISPLAY : None
    DISPLAY         : Some("/private/tmp/com.apple.launchd.5hs4iDAPRl/org.xquartz:0")

SSH
    shared.in_ssh_connection: false

WSL
    /proc/sys/fs/binfmt_misc/WSLInterop: false

Variables
    SHELL              : Some("/bin/zsh")
    EDITOR             : Some("nvim")
    ZELLIJ_SESSION_NAME: None
    YAZI_FILE_ONE      : None
    YAZI_CONFIG_HOME   : None

Text Opener
    default: Some(Opener { run: "${EDITOR:=vi} \"$@\"", block: true, orphan: false, desc: "$EDITOR", for_: None, spread: true })
    block  : Some(Opener { run: "${EDITOR:=vi} \"$@\"", block: true, orphan: false, desc: "$EDITOR", for_: None, spread: true })

tmux
    TMUX   : false
    Version: tmux 3.3a

Dependencies
    file             : 5.41
    ueberzugpp       : 2.9.2
    ffmpegthumbnailer: 2.2.2
    magick           : 7.1.1-33
    fzf              : 0.46.1
    fd               : 9.0.0
    rg               : 14.1.0
    chafa            : 1.14.0
    zoxide           : 0.9.4
    unar             : 1.10.7
    jq               : 1.7.1


--------------------------------------------------
When reporting a bug, please also upload the `yazi.log` log file - only upload the most recent content by time.
You can find it in the "/Users/mikavilpas/.local/state/yazi" directory.

yazi.log doesn't show anything related to this


  2024-06-17T15:35:50.436808Z  WARN yazi_adaptor::adaptor: [Adaptor] Could not identify XDG_SESSION_TYPE
    at yazi-adaptor/src/adaptor.rs:98

  2024-06-17T15:38:33.628389Z  WARN yazi_adapter::adapter: [Adapter] Could not identify XDG_SESSION_TYPE
    at yazi-adapter/src/adapter.rs:97

  2024-06-17T15:38:35.419921Z  WARN yazi_adapter::adapter: [Adapter] Could not identify XDG_SESSION_TYPE
    at yazi-adapter/src/adapter.rs:97

Describe the bug

Generally bat and yazi have similar results when highlighting a file. I noticed there are some special cases this isn't true: bat provides syntax highlighting but yazi does not highlight the syntax.

Expected Behavior

yazi shows syntax highlighting like bat

To Reproduce

For example, bat is able to highlight its own config file image

But yazi shows this file as unhighlighted image

Configuration

https://github.com/mikavilpas/dotfiles/blob/98e2c1122657a096425e7967a9a24c340f8f60b6/.config/yazi/yazi.toml?plain=1#L1

Anything else?

This seems to be a feature of bat, using the following heuristics that are based on file paths and names: https://github.com/sharkdp/bat/blob/c264ecd26b16ebb4f309db03d5a16b1f6e38ca67/src/syntax_mapping/builtins/README.md?plain=1#L1

I'm not sure what files are highlighted or not. As far as I can see, yazi just calls syntect to figure out what syntax should be used.

Do you think this should be fixed?