2.1 KiB
2.1 KiB
yafg.yazi (Yet Another FG)
Fuzzy find and grep in Yazi using ripgrep and fzf. This plugin provides an interactive search interface that allows you to search file contents and open results directly in your configured editor.
Inspired by fg.yazi
Requirements
bashrg(ripgrep)fzfbat- A text editor (default:
hxHelix)
Installation
Install the plugin via the package manager:
ya pkg add XYenon/yafg
This clones the repository, adds it to ~/.config/yazi/package.toml, and pins the current revision.
Usage
Add a shortcut in ~/.config/yazi/keymap.toml:
[[mgr.prepend_keymap]]
on = [ "F", "G" ]
run = "plugin yafg"
Configuration
Customize the editor and command format in ~/.config/yazi/init.lua:
require("yafg"):setup({
editor = "nvim", -- Editor command (default: "hx")
args = { "--noplugin" }, -- Additional editor arguments (default: {})
file_arg_format = "+{row} {file}", -- File argument format (default: "{file}:{row}:{col}")
})
Format placeholders:
{file}- File path{row}- Line number{col}- Column number
Features
- Interactive search: Use ripgrep to search file contents with live preview
- Switch modes: Press
Ctrl-Tto toggle between ripgrep and fzf modes - Multi-select: Select multiple search results
- Preview: View file contents with syntax highlighting via bat
- Direct open: Opens selected files in your configured editor at the matched line
- Configurable: Customize editor command, arguments, and file format
Troubleshooting
- Failed to start fzf: ensure all required dependencies are installed (
rg,fzf,bat,bash). - Preview not working: install
batfor syntax-highlighted previews. - Editor not opening: ensure your configured editor is installed and in your PATH, or customize it in
init.lua.
Development
This repository uses treefmt for formatting:
nix fmt
Feel free to open a PR to add more features or support additional editors.