Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
mikavilpas opened this issue Jun 17, 2024 · 3 comments
Open

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

mikavilpas opened this issue Jun 17, 2024 · 3 comments
Labels
feature New feature request

Comments

@mikavilpas
Copy link
Contributor

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

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?

@mikavilpas mikavilpas added the bug Something isn't working label Jun 17, 2024
@sxyazi
Copy link
Owner

sxyazi commented Jun 18, 2024

Nice to have, but I think it should use mine-type as the fallback rather than path as this will allow users to choose desired mime fetcher to meets their different needs

@sxyazi sxyazi changed the title Add support for bat's "path/name based mappings" for highlighting Add support for using mime-type as the fallback for highlighting Jun 18, 2024
@sxyazi sxyazi added feature New feature request and removed bug Something isn't working labels Jun 18, 2024
@sxyazi
Copy link
Owner

sxyazi commented Jun 18, 2024

Or maybe only use mine-type (instead of the extension of current implementation) since it's more accurate and flexible

@haennes
Copy link

haennes commented Jul 15, 2024

Hey, great project :)
I have a similar problem with $ file returning
test.xopp: gzip compressed data, from Unix, original size modulo 2^32 8510711
which technically is correct. (yazi unzips it succesfully and data makes sense)
However I want these files (having a mimetype of application/x-xopp) to be opened by xournalpp
As expected xdg-open works just fine

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature request
Projects
None yet
Development

No branches or pull requests

3 participants