[mgr]
# it also support --mode=or when using with --input or --keys=!1q or --key=!1q or --tag=!1q or --tags=!1q
ratio = [2, 3, 5]
sort_by = "natural"
sort_sensitive = false
sort_reverse = false
sort_dir_first = true
linemode = "none"
show_hidden = true
show_symlink = true
scrolloff = 5

[preview]
tab_size = 2
max_width = 600
max_height = 900
cache_dir = ""
image_delay = 30
image_filter = "triangle"
image_quality = 75

[opener]
# edit = [
#   { run = '$EDITOR "$@"', block = true, for = "unix" },
# ]
open = [{ run = 'xdg-open "$1"', desc = "Open", orphan = true }]
edit = [{ run = 'nvim "$@"', block = true, desc = "nvim", for = "unix" }]
reveal = [
  { run = 'xdg-open "$(dirname "$1")"', desc = "Reveal", for = "linux" },
]
play = [{ run = 'mpv --force-window "$@"', orphan = true, for = "unix" }]
pdf = [{ run = 'zathura "$@"', orphan = true, for = "linux" }]
text = [{ run = 'nvim "$@"', block = true, for = "linux" }]
epub = [{ run = 'epy "$@"', orphan = true, for = "linux" }]

[open]
rules = [
  # Empty files
  { mime = "inode/empty", use = "edit" },
  # { mime = "inode/x-empty", use = "edit" },
  # Text files - use edit (which uses $EDITOR/nvim)
  { mime = "text/*", use = "edit" }, # Changed from "text" to "edit"
  # { mime = "text/x-tex", use = "edit" },  # Changed from "text" to "edit"
  { mime = "application/json", use = "edit" },
  { mime = "application/x-sh", use = "edit" },
  { mime = "application/x-shellscript", use = "edit" },
  { mime = "application/javascript", use = "edit" },
  # Fallback by extension
  { url = "*.sh", use = "edit" },
  { url = "*.json", use = "edit" },
  { url = "*.md", use = "edit" },
  { url = "*.txt", use = "edit" },
  { url = "*.css", use = "edit" },
  { url = "*.js", use = "edit" },
  { url = "*.toml", use = "edit" },
  { url = "*.yaml", use = "edit" },
  { url = "*.yml", use = "edit" },
  { url = "*.tex", use = "edit" },  # Uncommented!
  { url = "*.text", use = "edit" },
  { url = "*.epub", use = "edit" },
  { url = "*,kdl", use = "edit" },
  # Media files
  { mime = "image/*", use = "open" },
  { mime = "video/*", use = "play" },
  { mime = "audio/*", use = "play" },
  { mime = "application/pdf", use = "pdf" },
  # Fallback
  { mime = "*", use = "open" },
]

[tasks]
micro_workers = 10
macro_workers = 25
bizarre_retry = 5
suppress_preload = false

[plugin]
prepend_fetchers = [
  { group = "mime", id = "mime", url = "*", run = "mime-ext", prio = "high" },
  # git plugin
  { group = "mime", id = "git", url = "*", run = "git" },
  { group = "mime", id = "git", url = "*/", run = "git" },
  # mime plugin
  { group = "mime", id = "simple-tag", url = "*", run = "simple-tag" },
  { group = "mime", id = "simple-tag", url = "*/", run = "simple-tag" },
]
preloaders = [
  # Image
  { mime = "image/{avif,hei?,jxl,svg+xml}", run = "magick" },
  { mime = "image/*", run = "image" },
  # Video
  # { mime = "video/*", run = "video" },
  # PDF
  { mime = "application/pdf", run = "pdf" },
  # Font
  { mime = "font/*", run = "font" },
  { mime = "application/ms-opentype", run = "font" },
]
prepend_preloaders = [
  # Replace magick, image, video with mediainfo
  { mime = "{audio,video,image}/*", run = "mediainfo" },
  { mime = "application/subrip", run = "mediainfo" },
  # Adobe Illustrator, Adobe Photoshop is image/adobe.photoshop, already handled above
  { mime = "application/postscript", run = "mediainfo" },
]
spotters = [
  # extra-metadata plugin
  { url = "*", run = "file-extra-metadata" },
]
previewers = [
  { url = "*/", run = "folder", sync = true },
  # Code
  { url = "text/*", run = "code" },
  { url = "*/{xml,javascript,wine-extension-ini}", run = "code" },
  # JSON
  { url = "application/{json,ndjson}", run = "json" },
  # Image
  { url = "image/{avif,hei?,jxl,svg+xml}", run = "magick" },
  { url = "image/*", run = "image" },
  # # Video
  # { mime = "video/*", run = "video" },
  # PDF
  { url = "application/pdf", run = "pdf" },
  # extra-metadata plugin
  { url = "*", run = "file-extra-metadata" },
]
prepend_previewers = [
  # mediainfo MUST come before the catch-all piper rule
  { mime = "{audio,video,image}/*", run = "mediainfo" },
  { mime = "application/subrip", run = "mediainfo" },
  { mime = "application/postscript", run = "mediainfo" },
  # ouch plugin for archives
  { mime = "application/{*zip,tar,bzip2,7z*,rar,xz,zstd,java-archive}", run = "ouch" },
  # piper for directories
  { url = "*/", run = 'piper -- eza -TL=3 --color=always --icons=always --group-directories-first --no-quotes "$1"' },
  # piper markdown (commented out as you had it)
  # rich preview plugin
  { url = "*.csv", run = "rich-preview" },   # for csv files
  { url = "*.md", run = "rich-preview" },    # for markdown (.md) files
  { url = "*.rst", run = "rich-preview" },   # for restructured text (.rst) files
  { url = "*.ipynb", run = "rich-preview" }, # for jupyter notebooks (.ipynb)
  { url = "*.json", run = "rich-preview" },  # for json (.json) files
  # { url = "*.lang_type", run = "rich-preview"} # for particular language files eg. .py, .go., .lua, etc.
]
