Yazi.nvim
A Neovim Plugin for the yazi terminal file manager
Install / Use
/learn @mikavilpas/Yazi.nvimREADME
🎲 A Neovim Plugin for yazi
<a href="https://dotfyle.com/plugins/mikavilpas/yazi.nvim"> <img src="https://dotfyle.com/plugins/mikavilpas/yazi.nvim/shield?style=flat-square" alt="shield image for plugin usage" /> </a>Yazi is a blazing fast file manager for the terminal. This plugin allows you to open yazi in a floating window in Neovim.
https://github.com/mikavilpas/yazi.nvim/assets/300791/c7ff98ee-54d6-4ad0-9318-903e4b674f84
✨ Features
- Press
<f1>to display all keymaps! - Open yazi in a floating window. All visible splits are opened as yazi tabs for easy and fast navigation.
- Files that are hovered in yazi are highlighted in Neovim to intuitively show where you are in relation to your Neovim session. Currently this works for splits that you have open.
- Files selected in yazi can be opened in various ways: as the current buffer, a
vertical split, a horizontal split, a new tab, as quickfix items...
- if you have selected a file path in visual mode, yazi will open that file instead of current file
- Integrations to other plugins and tools, if they are installed:
- For telescope.nvim, fzf-lua.nvim and snacks.picker: you can grep/search in the directory yazi is in. Select some files to limit the search to those files only.
- Using a bundled version of snacks.bufdelete to have yazi close buffers and preserve the window layout. This happens when files that are open are deleted in yazi.
- For grug-far.nvim: you can search and replace in the directory yazi is in
- Copy the relative path from the start file to the currently hovered file. Requires realpath (1) on linux and windows, or grealpath on osx
- If multiple files are selected, they can be sent to the quickfix list
- (optionally) open yazi instead of netrw for directories
- Files that are renamed, moved, or deleted in yazi are kept in sync with open
buffers in Neovim
- The files are also kept in sync with currently running LSP servers. A technical explanation is available in documentation/for-developers/lsp-renaming.md.
- Customizable keybindings
- Plugin management for Yazi plugins and flavors (documentation)
- 🆕 Send custom commands to yazi (documentation)
For previewing images with yazi, see Yazi's documentation related to Neovim.
📦 Installation
First, make sure you have the requirements:
- Neovim stable or nightly
- a recent version of yazi
- Opting into new features might require a recent version of yazi (see installing-yazi-from-source.md)
- if on Windows, the minimum supported version is Windows 11
[!TIP]
You can run
:checkhealth yazito see if compatible versions are installed and working.
⚙️ Configuration
Using lazy.nvim
This is the preferred installation method.
Notice that yazi.nvim adds and lazy loads some minimal dependencies for you automatically when using a plugin manager like lazy.nvim. To see which dependencies are installed, see lazy.lua. If you are not using lazy.nvim (or rocks.nvim), you need to install the dependencies yourself. Also see the discussion in issue 306 and examples of other Neovim plugins using this feature.
---@type LazySpec
return {
"mikavilpas/yazi.nvim",
version = "*", -- use the latest stable version
event = "VeryLazy",
dependencies = {
{ "nvim-lua/plenary.nvim", lazy = true },
},
keys = {
-- 👇 in this section, choose your own keymappings!
{
"<leader>-",
mode = { "n", "v" },
"<cmd>Yazi<cr>",
desc = "Open yazi at the current file",
},
{
-- Open in the current working directory
"<leader>cw",
"<cmd>Yazi cwd<cr>",
desc = "Open the file manager in nvim's working directory",
},
{
"<c-up>",
"<cmd>Yazi toggle<cr>",
desc = "Resume the last yazi session",
},
},
---@type YaziConfig | {}
opts = {
-- if you want to open yazi instead of netrw, see below for more info
open_for_directories = false,
keymaps = {
show_help = "<f1>",
},
},
-- 👇 if you use `open_for_directories=true`, this is recommended
init = function()
-- mark netrw as loaded so it's not loaded at all.
--
-- More details: https://github.com/mikavilpas/yazi.nvim/issues/802
vim.g.loaded_netrwPlugin = 1
end,
}
Without a package manager
<details> <summary>Instructions</summary>If you are not using lazy.nvim, see lazy.lua for what dependencies are required.
-- (Obtain yazi.nvim and its dependencies using your preferred method first)
--
-- Next, map a key to open yazi.nvim
vim.keymap.set("n", "<leader>-", function()
require("yazi").yazi()
end)
-- 👇 if you use `open_for_directories=true`, this is recommended.
--
-- mark netrw as loaded so it's not loaded at all.
-- More details: https://github.com/mikavilpas/yazi.nvim/issues/802
vim.g.loaded_netrwPlugin = 1
vim.api.nvim_create_autocmd("UIEnter", {
callback = function()
require("yazi").setup({
open_for_directories = true,
})
end,
})
</details>
⌨️ Keybindings
These are the default keybindings that are available when yazi is open:
<f1>: show the help menu<c-v>: open the selected file(s) in vertical splits<c-x>: open the selected file(s) in horizontal splits<c-t>: open the selected file(s) in new tabs<c-q>: send the selected file(s) to the quickfix list- There are also integrations to other plugins, which you need to install
separately:
<c-s>: search in the current yazi directory using telescope'slive_grep, if available. Optionally you can use fzf-lua.nvim, snacks.picker or provide your own implementation - see the instructions in the configuration section for more info.- if multiple files/directories are selected in yazi, the search and replace will only be done in the selected files/directories
<c-g>: search and replace in the current yazi directory using grug-far, if available- if multiple files/directories are selected in yazi, the operation is limited to those only
<c-y>: copy the relative path of the selected file(s) to the clipboard. Requires GNUrealpathorgrealpathon OSX- also available for the snacks.nvim picker, see documentation/copy-relative-path-to-files.md for more information
<tab>: make yazi jump to the open buffers in Neovim. See #232 for more information
⚙️⚙️ Advanced configuration
[!IMPORTANT]
You don't have to set any of these options. The defaults are fine for most users.
For advanced configuration, it's recommended to have your Lua language server set up so that you can type check your configuration and avoid errors.
For help on how to do this, there is a section for Neovim development tools in the documentation.
You can optionally configure yazi.nvim by setting any of the options below.
return {
-- ... other lazy.nvim configuration from above
---@type YaziConfig | {}
opts = {
-- Below is the default configuration. It is optional to set these values.
-- You can customize the configuration for each yazi call by passing it to
-- yazi() explicitly
-- enable this if you want to open yazi instead of netrw.
-- Note that if you enable this, you need to call yazi.setup() to
-- initialize the plugin. lazy.nvim does this for you in certain cases.
--
-- If you are also using neotree, you may prefer not to bring it up when
-- opening a directory:
-- {
-- "nvim-neo-tree/neo-tree.nvim",
-- opts = {
-- filesystem = {
-- hijack_netrw_behavior = "disabled",
-- },
-- },
-- }
open_for_directories = false,
-- open visible splits and quickfix items as yazi tabs for easy navigation
-- https://github.com/mikavilpas/yazi.nvim/pull/359
open_multiple_tabs = false,
-- when yazi is closed with no file chosen, change the Neovim working
-- directory to the directory that yazi was in before it was closed. Defaults
-- to being off (`false`)
change_neovim_cwd_on_close = false,
highlight_groups = {
-- See https://github.com/mikavilpas/yazi.nvim/pull/180
hovered_buffer = nil,
-- See https://github.com/mikavilpas/yazi.nvim/pull/351
hovered_buff
