feat(plugins): replace yazi.nvim with persistent yazi session and disable neo-tree

This commit is contained in:
Prad Nukala committed 2026-08-10 17:10:08 -04:00
1 parent 384e9cf4ed
commit 546dc64684
2 files changed
+77 -82

No files matched your search

+76 -81
View File
@@ -1,91 +1,86 @@
--- Yazi as the default file manager (full neo-tree replacement)
--- Yazi as the default file manager (persistent session, full neo-tree
--- replacement). yazi.nvim was removed: it spawns a NEW yazi process on
--- every toggle (only the last-hovered path survives), so tab arrangements
--- were lost and each <C-e> "created a new tab for the workspace". Instead,
--- lua/config/yazi_session.lua keeps ONE yazi process alive in a snacks
--- terminal and <C-e> just hides/shows it — same session, same tabs.
--- File opens come back via ~/.local/bin/yazi-nvim-open -> _G.EditFromYazi
--- (edit / <C-v> vsplit / <C-x> split, bound yazi-side in keymap.toml).
---@type LazySpec
return {
{
"mikavilpas/yazi.nvim",
version = "*", -- latest stable release
event = "VeryLazy",
dependencies = {
{ "nvim-lua/plenary.nvim", lazy = true },
},
keys = {
{
"<leader>-",
mode = { "n", "v" },
"<cmd>Yazi<cr>",
desc = "Open yazi at the current file",
},
{
"<leader>cw",
"<cmd>Yazi cwd<cr>",
desc = "Open yazi in nvim's working directory",
},
{
-- replaces AstroNvim's <Leader>o "Toggle Explorer Focus" (neo-tree)
"<leader>o",
"<cmd>Yazi<cr>",
desc = "Open Explorer (yazi at current file)",
},
{
"<C-e>",
mode = { "n", "v", "t" },
function()
-- true toggle: if a yazi window is already open, quit it instead
-- of nesting a second instance (yazi.nvim's toggle() always spawns)
for _, win in ipairs(vim.api.nvim_list_wins()) do
local buf = vim.api.nvim_win_get_buf(win)
if vim.bo[buf].filetype == "yazi" then
-- send `q` to the yazi process so it exits gracefully and
-- saves its state for the next resume
vim.api.nvim_chan_send(vim.bo[buf].channel, "q")
return
end
end
vim.cmd "Yazi toggle"
end,
desc = "Toggle yazi (resume last session)",
},
},
---@type YaziConfig | {}
"folke/snacks.nvim",
opts = {
-- yazi replaces netrw/neo-tree when opening directories (nvim .)
open_for_directories = true,
-- keep a single yazi tab: `true` would pass every visible split as an
-- extra path arg, and each one becomes a yazi tab that then persists
-- across <C-e> toggles (resume), piling up tabs over time
open_multiple_tabs = false,
-- occupy the whole screen instead of a floating popup
floating_window_scaling_factor = 1,
yazi_floating_window_border = "none",
keymaps = {
show_help = "<f1>",
-- Open the hovered/selected file(s) as nvim splits. These are
-- buffer-local terminal-mode keymaps on the yazi buffer, so nvim
-- intercepts the chord before the yazi process ever sees it --
-- nothing is needed in ~/.config/yazi/keymap.toml. Chords match
-- the telescope/snacks picker convention (<c-v>/<c-x>/<c-t>).
open_file_in_vertical_split = "<c-v>",
open_file_in_horizontal_split = "<c-x>",
-- NOTE: the default <c-t> (open in tab) shadows the yazi-side
-- <C-t> "plugin tv" bind from keymap.toml while inside nvim;
-- set open_file_in_tab = false to let <C-t> reach yazi/tv instead
open_file_in_tab = "<c-t>",
-- ~/.config/yazi/keymap.toml binds <C-q> to quit inside yazi;
-- don't hijack it for the quickfix list (multi-select still goes
-- to the quickfix list via the default yazi_opened_multiple_files)
send_to_quickfix_list = false,
},
integrations = {
-- <c-y> copy-relative-path action inside snacks pickers too
picker_add_copy_relative_path_action = "snacks.picker",
styles = {
-- fullscreen borderless float for the yazi session terminal
yazi = {
position = "float",
width = 0,
height = 0,
border = "none",
backdrop = false,
},
},
},
init = function()
-- netrw is fully replaced by yazi (open_for_directories)
vim.g.loaded_netrwPlugin = 1
end,
},
-- neo-tree is fully replaced by yazi.nvim
{
"AstroNvim/astrocore",
opts = {
mappings = {
n = {
["<C-e>"] = {
function() require("config.yazi_session").toggle() end,
desc = "Toggle yazi (persistent session)",
},
["<Leader>-"] = {
function() require("config.yazi_session").open_current() end,
desc = "Open yazi at the current file",
},
["<Leader>o"] = {
function() require("config.yazi_session").open_current() end,
desc = "Open Explorer (yazi at current file)",
},
["<Leader>cw"] = {
function() require("config.yazi_session").open(vim.uv.cwd()) end,
desc = "Open yazi in nvim's working directory",
},
},
v = {
["<C-e>"] = {
function() require("config.yazi_session").toggle() end,
desc = "Toggle yazi (persistent session)",
},
},
t = {
["<C-e>"] = {
function() require("config.yazi_session").toggle() end,
desc = "Toggle yazi (persistent session)",
},
},
},
autocmds = {
-- netrw is disabled in lazy_setup.lua (performance.rtp.disabled_plugins);
-- directory buffers (nvim . / :e dir) open in the yazi session instead
yazi_dir_hijack = {
{
event = "BufEnter",
desc = "Open directory buffers in the yazi session",
callback = function(args)
local path = vim.api.nvim_buf_get_name(args.buf)
if path == "" or vim.fn.isdirectory(path) == 0 then return end
vim.bo[args.buf].bufhidden = "wipe"
vim.schedule(function()
if vim.api.nvim_get_current_buf() == args.buf then vim.cmd.enew() end
require("config.yazi_session").open(path)
end)
end,
},
},
},
},
},
-- neo-tree is fully replaced by the yazi session
{ "nvim-neo-tree/neo-tree.nvim", enabled = false },
}