Moved yazi dotfiles to the dotfiles subrepo

This commit is contained in:
2025-04-22 14:28:52 +01:00
parent 2a73fa8dcf
commit 02772db785
13 changed files with 204 additions and 7 deletions

27
.gitmodules vendored
View File

@@ -13,3 +13,30 @@
[submodule "dot_config/micro/plug/lsp"]
path = dot_config/micro/plug/lsp
url = https://github.com/AndCake/micro-plugin-lsp.git
[submodule "dot_config/yazi/plugins/hexyl.yazi"]
path = dot_config/yazi/plugins/hexyl.yazi
url = https://github.com/Reledia/hexyl.yazi
[submodule "dot_config/yazi/flavors/tokyo-night.yazi"]
path = dot_config/yazi/flavors/tokyo-night.yazi
url = https://github.com/BennyOe/tokyo-night.yazi.git
[submodule "dot_config/yazi/plugins/sudo.yazi"]
path = dot_config/yazi/plugins/sudo.yazi
url = https://github.com/TD-Sky/sudo.yazi
[submodule "dot_config/yazi/plugins/core"]
path = dot_config/yazi/plugins/core
url = https://github.com/yazi-rs/plugins
[submodule "dot_config/yazi/plugins/ouch.yazi"]
path = dot_config/yazi/plugins/ouch.yazi
url = https://github.com/ndtoan96/ouch.yazi
[submodule "dot_config/yazi/plugins/starship.yazi"]
path = dot_config/yazi/plugins/starship.yazi
url = https://github.com/Rolv-Apneseth/starship.yazi
[submodule "dot_config/yazi/plugins/glow.yazi"]
path = dot_config/yazi/plugins/glow.yazi
url = https://github.com/Reledia/glow.yazi
[submodule "dot_config/yazi/plugins/wl-clipboard.yazi"]
path = dot_config/yazi/plugins/wl-clipboard.yazi
url = https://github.com/grappas/wl-clipboard.yazi
[submodule "dot_config/yazi/plugins/rich-preview.yazi"]
path = dot_config/yazi/plugins/rich-preview.yazi
url = https://github.com/AnirudhG07/rich-preview.yazi

View File

@@ -1,5 +1,3 @@
"$schema" = "https://yazi-rs.github.io/schemas/keymap.json"
[manager]
keymap = [
@@ -257,6 +255,48 @@ keymap = [
# Help
{ on = "~", run = "help", desc = "Open help" },
{ on = "<F1>", run = "help", desc = "Open help" },
# Sudo
{ on = [
"R",
"p",
"p",
], run = "plugin sudo -- paste", desc = "sudo paste" },
{ on = [
"R",
"P",
], run = "plugin sudo -- paste --force", desc = "sudo paste" },
{ on = [
"R",
"r",
], run = "plugin sudo -- rename", desc = "sudo rename" },
{ on = [
"R",
"p",
"l",
], run = "plugin sudo -- link", desc = "sudo link" },
{ on = [
"R",
"p",
"r",
], run = "plugin sudo -- link --relative", desc = "sudo link relative path" },
{ on = [
"R",
"p",
"L",
], run = "plugin sudo -- hardlink", desc = "sudo hardlink" },
{ on = [
"R",
"a",
], run = "plugin sudo -- create", desc = "sudo create" },
{ on = [
"R",
"d",
], run = "plugin sudo -- remove", desc = "sudo trash" },
{ on = [
"R",
"D",
], run = "plugin sudo -- remove --permanently", desc = "sudo delete" },
]
[tasks]
@@ -489,3 +529,19 @@ desc = "Chmod on selected files"
on = "T"
run = "plugin --sync max-preview"
desc = "Maximize or restore preview"
[[manager.prepend_keymap]]
on = "<C-y>"
run = ["plugin wl-clipboard"]
desc = "Yank to wl-clipboard"
[[manager.prepend_keymap]]
on = ["C"]
run = "plugin ouch"
desc = "Compress with ouch"
[opener]
extract = [
{ run = 'ouch d -y "%*"', desc = "Extract here with ouch", for = "windows" },
{ run = 'ouch d -y "$@"', desc = "Extract here with ouch", for = "unix" },
]

View File

@@ -0,0 +1,30 @@
# glow.yazi
Plugin for [Yazi](https://github.com/sxyazi/yazi) to preview markdown files with [glow](https://github.com/charmbracelet/glow). To install, run the below mentioned command:
```bash
ya pack -a Reledia/glow
```
then include it in your `yazi.toml` to use:
```toml
[plugin]
prepend_previewers = [
{ name = "*.md", run = "glow" },
]
```
Make sure you have [glow](https://github.com/charmbracelet/glow) installed, and can be found in `PATH`.
## Feature
+ You can modify line wrap in `main.lua`, the current value is 55.
+ You can press `ctrl+e` to scroll up and `ctrl+y` to scroll down the readme file in preview panel in yazi: (add this to `keymap.toml`)
```toml
prepend_keymap = [
# glow.yazi
{ on = ["<C-e>"], run = "seek 5" },
{ on = ["<C-y>"], run = "seek -5" },
]
```

View File

@@ -0,0 +1,64 @@
local M = {}
function M:peek(job)
-- Set a fixed width of 50 characters for the preview
local preview_width = 55
local child = Command("glow")
:args({
"--style",
"dark",
"--width",
tostring(preview_width), -- Use fixed width instead of job.area.w
tostring(job.file.url),
})
:env("CLICOLOR_FORCE", "1")
:stdout(Command.PIPED)
:stderr(Command.PIPED)
:spawn()
if not child then
return require("code").peek(job)
end
local limit = job.area.h
local i, lines = 0, ""
repeat
local next, event = child:read_line()
if event == 1 then
return require("code").peek(job)
elseif event ~= 0 then
break
end
i = i + 1
if i > job.skip then
lines = lines .. next
end
until i >= job.skip + limit
child:start_kill()
if job.skip > 0 and i < job.skip + limit then
ya.mgr_emit("peek", {
tostring(math.max(0, i - limit)),
only_if = job.file.url,
upper_bound = true
})
else
lines = lines:gsub("\t", string.rep(" ", rt.preview.tab_size))
ya.preview_widgets(job, { ui.Text.parse(lines):area(job.area) })
end
end
function M:seek(job)
local h = cx.active.current.hovered
if not h or h.url ~= job.file.url then
return
end
ya.mgr_emit('peek', {
math.max(0, cx.active.preview.skip + job.units),
only_if = job.file.url,
})
end
return M

View File

@@ -1,12 +1,24 @@
[plugin]
prepend_previewers = [
{ name = "*.md", run = "glow" },
{ name = "*.bin", run = "hexyl" },
{ name = "*.md", run = "glow" },
{ name = "*.bin", run = "hexyl" },
]
append_previewers = [
{ name = "*", run = "hexyl" },
{ name = "*.md", run = "glow" },
{ name = "*.csv", run = "rich-preview" },
{ name = "*.rst", run = "rich-preview" },
{ name = "*.ipynb", run = "rich-preview" },
{ name = "*.json", run = "rich-preview" },
{ mime = "application/*zip", run = "ouch" },
{ mime = "application/x-tar", run = "ouch" },
{ mime = "application/x-bzip2", run = "ouch" },
{ mime = "application/x-7z-compressed", run = "ouch" },
{ mime = "application/x-rar", run = "ouch" },
{ mime = "application/x-xz", run = "ouch" },
{ mime = "application/xz", run = "ouch" },
{ name = "*", run = "hexyl" },
]
prepend_fetchers = [
{ id = "git", name = "*", run = "git" },
{ id = "git", name = "*/", run = "git" },
{ id = "git", name = "*", run = "git" },
{ id = "git", name = "*/", run = "git" },
]