Yazi plugin

This commit is contained in:
2025-11-11 21:51:41 +00:00
parent 2062c442b2
commit 8e2d413e0a
4 changed files with 112 additions and 73 deletions

View File

@@ -2,57 +2,57 @@
-- https://github.com/nvim-neo-tree/neo-tree.nvim
return {
'nvim-neo-tree/neo-tree.nvim',
version = '*',
dependencies = {
'nvim-lua/plenary.nvim',
'nvim-tree/nvim-web-devicons', -- not strictly required, but recommended
'MunifTanjim/nui.nvim',
},
cmd = 'Neotree',
keys = {
{ '\\', ':Neotree reveal<CR>', desc = 'NeoTree reveal', silent = true },
},
build = function()
if vim.fn.executable 'fd' == 0 then
local install_cmd
if vim.fn.has 'mac' == 1 then
install_cmd = 'brew install fd'
elseif vim.fn.has 'unix' == 1 then
if vim.fn.filereadable '/etc/arch-release' == 1 then
install_cmd = 'sudo pacman -S --noconfirm fd'
else
install_cmd = 'sudo apt-get install -y fd-find'
end
else
vim.notify("Please install 'fd' manually for neo-tree.", vim.log.levels.WARN)
return
end
vim.fn.system(install_cmd)
end
end,
opts = function(_, opts)
local function on_move(data)
Snacks.rename.on_rename_file(data.source, data.destination)
end
local events = require 'neo-tree.events'
opts.event_handlers = opts.event_handlers or {}
vim.list_extend(opts.event_handlers, {
{ event = events.FILE_MOVED, handler = on_move },
{ event = events.FILE_RENAMED, handler = on_move },
})
opts.filesystem = {
window = {
mappings = {
['\\'] = 'close_window',
},
},
filtered_items = {
hide_dotfiles = false,
},
}
end,
-- 'nvim-neo-tree/neo-tree.nvim',
-- version = '*',
-- dependencies = {
-- 'nvim-lua/plenary.nvim',
-- 'nvim-tree/nvim-web-devicons', -- not strictly required, but recommended
-- 'MunifTanjim/nui.nvim',
-- },
-- cmd = 'Neotree',
-- keys = {
-- { '\\', ':Neotree reveal<CR>', desc = 'NeoTree reveal', silent = true },
-- },
--
-- build = function()
-- if vim.fn.executable 'fd' == 0 then
-- local install_cmd
-- if vim.fn.has 'mac' == 1 then
-- install_cmd = 'brew install fd'
-- elseif vim.fn.has 'unix' == 1 then
-- if vim.fn.filereadable '/etc/arch-release' == 1 then
-- install_cmd = 'sudo pacman -S --noconfirm fd'
-- else
-- install_cmd = 'sudo apt-get install -y fd-find'
-- end
-- else
-- vim.notify("Please install 'fd' manually for neo-tree.", vim.log.levels.WARN)
-- return
-- end
-- vim.fn.system(install_cmd)
-- end
-- end,
--
-- opts = function(_, opts)
-- local function on_move(data)
-- Snacks.rename.on_rename_file(data.source, data.destination)
-- end
-- local events = require 'neo-tree.events'
-- opts.event_handlers = opts.event_handlers or {}
-- vim.list_extend(opts.event_handlers, {
-- { event = events.FILE_MOVED, handler = on_move },
-- { event = events.FILE_RENAMED, handler = on_move },
-- })
--
-- opts.filesystem = {
-- window = {
-- mappings = {
-- ['\\'] = 'close_window',
-- },
-- },
-- filtered_items = {
-- hide_dotfiles = false,
-- },
-- }
-- end,
}

View File

@@ -1,23 +1,23 @@
-- Filesystem manager
require('helpers').edit_cf('po', '/lua/plugins/oil.lua')
vim.keymap.set('n', '-', '<CMD>Oil<CR>', { desc = 'Open parent directory' })
-- require('helpers').edit_cf('po', '/lua/plugins/oil.lua')
--
-- vim.keymap.set('n', '-', '<CMD>Oil<CR>', { desc = 'Open parent directory' })
return {
'stevearc/oil.nvim',
---@module 'oil'
---@type oil.SetupOpts
opts = {
view_options = {
show_hidden = true,
},
keymaps = {
['<C-p>'] = false,
},
},
-- Optional dependencies
dependencies = { { 'echasnovski/mini.icons', opts = {} } },
-- dependencies = { "nvim-tree/nvim-web-devicons" }, -- use if you prefer nvim-web-devicons
-- Lazy loading is not recommended because it is very tricky to make it work correctly in all situations.
lazy = false,
-- 'stevearc/oil.nvim',
-- ---@module 'oil'
-- ---@type oil.SetupOpts
-- opts = {
-- view_options = {
-- show_hidden = true,
-- },
-- keymaps = {
-- ['<C-p>'] = false,
-- },
-- },
-- -- Optional dependencies
-- dependencies = { { 'echasnovski/mini.icons', opts = {} } },
-- -- dependencies = { "nvim-tree/nvim-web-devicons" }, -- use if you prefer nvim-web-devicons
-- -- Lazy loading is not recommended because it is very tricky to make it work correctly in all situations.
-- lazy = false,
}

39
lua/plugins/yazi.lua Normal file
View File

@@ -0,0 +1,39 @@
---@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!
{
'-',
mode = { 'n', 'v' },
'<cmd>Yazi<cr>',
desc = 'Open yazi at the current file',
},
{
-- Open in the current working directory
'\\',
'<cmd>Yazi cwd<cr>',
desc = "Open the file manager in nvim's working directory",
},
},
---@type YaziConfig | {}
opts = {
-- if you want to open yazi instead of netrw, see below for more info
open_for_directories = true,
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,
}