sxyazi / yazi

💥 Blazing fast terminal file manager written in Rust, based on async I/O.
https://yazi-rs.github.io
MIT License
14.46k stars 329 forks source link

More spacing after icons "Folder:icon()" solution doesn't work as expected #647

Closed moshpirit closed 7 months ago

moshpirit commented 7 months ago

What system are you running Yazi on?

Linux X11

What terminal are you running Yazi in?

Konsole

Yazi version

yazi 0.1.5

Did you try the latest main branch to see if the problem has already been fixed?

Tried, but the problem is still present

Describe the bug

Since I can't comment on #297, I need to open a new issue, but I'm exactly at the same position as discussed there: I'd like more space after the icons.

The problem is that I cannot make the solution provided to work with me.

Expected Behavior

Nothing seems to have changed.

To Reproduce

  1. Create the ui.lua file with the command provided: echo "function Folder:icon(file) return ui.Span(\" \" .. file:icon() .. \" \") end" >> "$HOME/.config/yazi/ui.lua"
  2. Open the yazi.toml file and add the text under [plugin] (or create [plugins] and put it under that, nothing seems to change):
    preload = [
    "~/.config/yazi/ui.lua"
    ]
  3. Close your terminal and open yazi on a new one

Configuration

I haven't changed anything that I recall from the default configuration, except for what is mentioned above:


# A TOML linter such as https://taplo.tamasfe.dev/ can use this schema to validate your config.
# If you encounter any issues, please make an issue at https://github.com/yazi-rs/schemas.
"$schema" = "https://yazi-rs.github.io/schemas/yazi.json"

[manager]
ratio          = [ 1, 4, 3 ]
sort_by        = "modified"
sort_sensitive = true
sort_reverse   = true
sort_dir_first = true
linemode       = "none"
show_hidden    = false
show_symlink   = true

[preview]
tab_size        = 2
max_width       = 600
max_height      = 900
cache_dir       = ""
image_filter    = "triangle"
image_quality   = 75
sixel_fraction  = 15
ueberzug_scale  = 1
ueberzug_offset = [ 0, 0, 0, 0 ]

[opener]
edit = [
    { exec = '$EDITOR "$@"', block = true,  for = "unix" },
    { exec = 'code "%*"',    orphan = true, for = "windows" },
]
open = [
    { exec = 'xdg-open "$@"',                desc = "Open", for = "linux" },
    { exec = 'open "$@"',                    desc = "Open", for = "macos" },
    { exec = 'start "" "%1"', orphan = true, desc = "Open", for = "windows" }
]
reveal = [
    { exec = 'open -R "$1"',                          desc = "Reveal", for = "macos" },
    { exec = 'explorer /select, "%1"', orphan = true, desc = "Reveal", for = "windows" },
    { exec = '''exiftool "$1"; echo "Press enter to exit"; read''', block = true, desc = "Show EXIF", for = "unix" },
]
extract = [
    { exec = 'unar "$1"', desc = "Extract here", for = "unix" },
    { exec = 'unar "%1"', desc = "Extract here", for = "windows" },
]
play = [
    { exec = 'mpv "$@"', orphan = true, for = "unix" },
    { exec = 'mpv "%1"', orphan = true, for = "windows" },
    { exec = '''mediainfo "$1"; echo "Press enter to exit"; read''', block = true, desc = "Show media info", for = "unix" },
]

[open]
rules = [
    { name = "*/", use = [ "edit", "open", "reveal" ] },

    { mime = "text/*",  use = [ "edit", "reveal" ] },
    { mime = "image/*", use = [ "open", "reveal" ] },
    { mime = "video/*", use = [ "play", "reveal" ] },
    { mime = "audio/*", use = [ "play", "reveal" ] },
    { mime = "inode/x-empty", use = [ "edit", "reveal" ] },

    { mime = "application/json", use = [ "edit", "reveal" ] },
    { mime = "*/javascript",     use = [ "edit", "reveal" ] },

    { mime = "application/zip",             use = [ "extract", "reveal" ] },
    { mime = "application/gzip",            use = [ "extract", "reveal" ] },
    { mime = "application/x-tar",           use = [ "extract", "reveal" ] },
    { mime = "application/x-bzip",          use = [ "extract", "reveal" ] },
    { mime = "application/x-bzip2",         use = [ "extract", "reveal" ] },
    { mime = "application/x-7z-compressed", use = [ "extract", "reveal" ] },
    { mime = "application/x-rar",           use = [ "extract", "reveal" ] },
    { mime = "application/xz",              use = [ "extract", "reveal" ] },

    { mime = "*", use = [ "open", "reveal" ] },
]

[tasks]
micro_workers    = 10
macro_workers    = 25
bizarre_retry    = 5
image_alloc      = 536870912  # 512MB
image_bound      = [ 0, 0 ]
suppress_preload = false

[plugin]

preloaders = [
    { name = "*", cond = "!mime", exec = "mime", multi = true, prio = "high" },
    # Image
    { mime = "image/vnd.djvu", exec = "noop" },
    { mime = "image/*",        exec = "image" },
    # Video
    { mime = "video/*", exec = "video" },
    # PDF
    { mime = "application/pdf", exec = "pdf" },
]
previewers = [
    { name = "*/", exec = "folder", sync = true },
    # Code
    { mime = "text/*",                 exec = "code" },
    { mime = "*/xml",                  exec = "code" },
    { mime = "*/javascript",           exec = "code" },
    { mime = "*/x-wine-extension-ini", exec = "code" },
    # JSON
    { mime = "application/json", exec = "json" },
    # Image
    { mime = "image/vnd.djvu", exec = "noop" },
    { mime = "image/*",        exec = "image" },
    # Video
    { mime = "video/*", exec = "video" },
    # PDF
    { mime = "application/pdf", exec = "pdf" },
    # Archive
    { mime = "application/zip",             exec = "archive" },
    { mime = "application/gzip",            exec = "archive" },
    { mime = "application/x-tar",           exec = "archive" },
    { mime = "application/x-bzip",          exec = "archive" },
    { mime = "application/x-bzip2",         exec = "archive" },
    { mime = "application/x-7z-compressed", exec = "archive" },
    { mime = "application/x-rar",           exec = "archive" },
    { mime = "application/xz",              exec = "archive" },
    # Fallback
    { name = "*", exec = "file" },
]

[plugins]

preload = [
    "~/.config/yazi/ui.lua"
]

[input]
# cd
cd_title  = "Change directory:"
cd_origin = "top-center"
cd_offset = [ 0, 2, 50, 3 ]

# create
create_title  = "Create:"
create_origin = "top-center"
create_offset = [ 0, 2, 50, 3 ]

# rename
rename_title  = "Rename:"
rename_origin = "hovered"
rename_offset = [ 0, 1, 50, 3 ]

# trash
trash_title     = "Move {n} selected file{s} to trash? (y/N)"
trash_origin    = "top-center"
trash_offset    = [ 0, 2, 50, 3 ]

# delete
delete_title    = "Delete {n} selected file{s} permanently? (y/N)"
delete_origin   = "top-center"
delete_offset   = [ 0, 2, 50, 3 ]

# filter
filter_title  = "Filter:"
filter_origin = "top-center"
filter_offset = [ 0, 2, 50, 3 ]

# find
find_title  = [ "Find next:", "Find previous:" ]
find_origin = "top-center"
find_offset = [ 0, 2, 50, 3 ]

# search
search_title  = "Search via {n}:"
search_origin = "top-center"
search_offset = [ 0, 2, 50, 3 ]

# shell
shell_title  = [ "Shell:", "Shell (block):" ]
shell_origin = "top-center"
shell_offset = [ 0, 2, 50, 3 ]

# overwrite
overwrite_title  = "Overwrite an existing file? (y/N)"
overwrite_origin = "top-center"
overwrite_offset = [ 0, 2, 50, 3 ]

# quit
quit_title  = "{n} task{s} running, sure to quit? (y/N)"
quit_origin = "top-center"
quit_offset = [ 0, 2, 50, 3 ]

[select]
open_title  = "Open with:"
open_origin = "hovered"
open_offset = [ 0, 1, 50, 7 ]

[log]
enabled = false

Anything else?

Cool software, btw :)

sxyazi commented 7 months ago

Hi! I noticed that you are using a rather old v0.1.5 of Yazi. Please use our latest v0.2.3 and add:

function Folder:icon(file)
    local icon = file:icon()
    return icon and ui.Span(" " .. icon.text .. "  "):style(icon.style) or ui.Span("")
end

to your ~/.config/yazi/init.lua it should work. This is its source code, you can change it to what you want in your init.lua: https://github.com/sxyazi/yazi/blob/25c96557edbc856523056ce67e5920cd3c3c076c/yazi-plugin/preset/components/folder.lua#L17-L20

moshpirit commented 7 months ago

Thanks for your quick response, @sxyazi! I found 2 issues related with how I installed yazi:

  1. I use Arch, so I installed the package from the extra repo with pacman. But the package seems to be out of date (and flagged as such), and there's an AUR version that is more updated, but it's giving me some error
  2. yazi doesn't seem to use ~/.config/yazi/ files for configuration, since completely removing yazi, removing the files and installing it again doesn't create any file at all. So I don't even know where are they created. I'll investigate this.
sxyazi commented 7 months ago

I use Arch, so I installed the package from the extra repo with pacman. But the package seems to be out of date (and flagged as such), and there's an AUR version that is more updated, but it's giving me some error

Ah that's a bit unfortunate, this is a known issue specific to ArchLinux, likely related to Rust/LLVM on ArchLinux, see https://github.com/sxyazi/yazi/issues/537, and we're currently unsure how to fix it. Could you please try installing via Cargo or building from source? You can also use our prebuilt binaries directly from https://github.com/sxyazi/yazi/releases

yazi doesn't seem to use ~/.config/yazi/ files for configuration, since completely removing yazi, removing the files and installing it again doesn't create any file at all. So I don't even know where are they created. I'll investigate this.

Yazi comes with the default configuration file pre-built at build time, if you want to customize the configuration see https://yazi-rs.github.io/docs/configuration/overview

sxyazi commented 7 months ago

Hi, the latest Yazi is now available on Arch Linux! https://github.com/sxyazi/yazi/issues/537#issuecomment-1937473903

moshpirit commented 7 months ago

I've just seen it! :partying_face: it works perfectly!! Thanks for everything! ❤️

github-actions[bot] commented 6 months ago

I'm going to lock this issue because it has been closed for 30 days. ⏳ This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.