From d3b7c61afd7d4c7dc1f314e47340d53e28482fbd Mon Sep 17 00:00:00 2001 From: Yasien Mac Mini Date: Wed, 13 May 2026 11:23:29 +0200 Subject: [PATCH] add file explorer to replace default explorer --- README.md | 26 +++++++++++++++++-- lazy-lock.json | 3 ++- lua/config/keybinds.lua | 53 ++++++++++++++++++++------------------- lua/config/options.lua | 5 ++++ lua/plugins/dashboard.lua | 9 ++++++- lua/plugins/yazi.lua | 29 +++++++++++++++++++++ 6 files changed, 95 insertions(+), 30 deletions(-) create mode 100644 lua/plugins/yazi.lua diff --git a/README.md b/README.md index 524fffc..cd94a6f 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ The **Leader Key** is set to `Space`. ### Dashboard | Action | Keybinding | Description | | :--- | :--- | :--- | -| **File Explorer** | `cd` | Open Netrw directly from the dashboard. | +| **File Explorer** | `cd` | Open Yazi directly from the dashboard. | | **Find Files** | `ff` | Fuzzy find files via Telescope. | | **Live Grep** | `fg` | Search across all files via Telescope. | | **Harpoon Menu** | `e` | Open the Harpoon quick menu. | @@ -37,11 +37,32 @@ The **Leader Key** is set to `Space`. | Action | Keybinding | Description | | :--- | :--- | :--- | | **Dashboard** | `;` | Open the MzansiVim Dasboard. | -| **File Explorer** | `cd` | Open the built-in Netrw explorer. | +| **File Explorer (Current Directory)** | `cd` | Open the Yazi explorer in current directory. | +| **File Explorer (Working Directory)** | `cw` | Open the Yazi explorer in working directory. | | **Find Files** | `ff` | Fuzzy find files in your project. | | **Live Grep** | `fg` | Search for specific text across all files. | | **Help Tags** | `fh` | Search through Neovim help documentation. | +### Yazi (File Explorer) +| Action | Keybinding | Description | +| :--- | :--- | :--- | +| **File Explorer** | `cd` | Open the Yazi explorer in file location. | +| **File Explorer** | `cw` | Open the Yazi explorer in working directory location. | +| **Navigation** | `h / j / k / l` | Move left (parent folder)/ down/ up/ or right (enter folder/open file). | +| **Open file** | `Enter` | Open file in new buffer. | +| **Open File (Horizontal Split)** | `Ctrl + x` | open file in horizontal split. | +| **Open File (Vertical Split)** | `Ctrl + v` | open file in horizontal split. | +| **Add file/ folder** | `a` | Create a new file (append / for a folder). | +| **Rename file/ folder** | `r` | Rename the highlighted file or directory. | +| **Delete file/ folder** | `d` | Move the selected item(s) to the system trash. | +| **Permanent Delete file/ folder** | `D` | Delete item(s) permanently (skips trash). | +| **Select file/ folder** | `space` | Toggle selection for the current file (allows batch actions). | +| **Bulk Select file/ folder** | `v` | Enter visual mode to select multiple files with `j/k` | +| **Copy / Cut** | `y / x` | Copy (Yank) or Cut the selected files. | +| **Paste** | `p` | Paste copied or cut files into the current directory. | +| **Help Menu** | `F1` | Open the help menu for keybindings. | +| **Close / Quit** | `q` | Exit Yazi and return to the Neovim buffer. | + ### Harpoon (Quick-Switching) | Action | Keybinding | Description | | :--- | :--- | :--- | @@ -124,6 +145,7 @@ To ensure all plugins (LSP, Tree-sitter, and Telescope) function correctly, plea * **Git** (For cloning the repo and managing plugins) * **Tree-sitter-cli** (For syntax highlighting) * **Ripgrep** (Required for Telescope live grep) +* **Yazi** (Required for file expolorer) * **Node & NPM** (Required for various LSP servers like `html` and `eslint`) * **Go** (Required for certain internal tools) diff --git a/lazy-lock.json b/lazy-lock.json index f30c8f6..dced191 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -29,5 +29,6 @@ "telescope-fzf-native.nvim": { "branch": "main", "commit": "6fea601bd2b694c6f2ae08a6c6fab14930c60e2c" }, "telescope.nvim": { "branch": "master", "commit": "5255aa27c422de944791318024167ad5d40aad20" }, "tokyonight.nvim": { "branch": "main", "commit": "cdc07ac78467a233fd62c493de29a17e0cf2b2b6" }, - "vim-fugitive": { "branch": "master", "commit": "3b753cf8c6a4dcde6edee8827d464ba9b8c4a6f0" } + "vim-fugitive": { "branch": "master", "commit": "3b753cf8c6a4dcde6edee8827d464ba9b8c4a6f0" }, + "yazi.nvim": { "branch": "main", "commit": "25f370e6e84ca7ebca5927ec66cd93e2fa16fd3d" } } diff --git a/lua/config/keybinds.lua b/lua/config/keybinds.lua index 5164b9a..46279a5 100644 --- a/lua/config/keybinds.lua +++ b/lua/config/keybinds.lua @@ -1,32 +1,33 @@ vim.g.mapleader = " " -vim.keymap.set("n", "cd", vim.cmd.Ex) +-- vim.keymap.set("n", "cd", vim.cmd.Ex) vim.keymap.set("n", ";", ":Dashboard", { desc = "Return to Dashboard", silent = true }) vim.api.nvim_create_autocmd("FileType", { - pattern = "netrw", - callback = function(event) - vim.schedule(function() - vim.keymap.set("n", "", function() - vim.cmd("enew") - vim.cmd("Dashboard") - end, { - buffer = event.buf, - nowait = true, - desc = "Return to Dashboard" - }) - end) - end, + pattern = "netrw", + callback = function(event) + vim.schedule(function() + vim.keymap.set("n", "", function() + vim.cmd("enew") + vim.cmd("Dashboard") + end, { + buffer = event.buf, + nowait = true, + desc = "Return to Dashboard" + }) + end) + end, }) vim.api.nvim_create_autocmd("FileType", { - pattern = "netrw", - callback = function(event) - vim.schedule(function() - vim.keymap.set("n", ";", function() - vim.cmd("enew") - vim.cmd("Dashboard") - end, { - buffer = event.buf, - nowait = true, desc = "Return to Dashboard" - }) - end) - end, + pattern = "netrw", + callback = function(event) + vim.schedule(function() + vim.keymap.set("n", ";", function() + vim.cmd("enew") + vim.cmd("Dashboard") + end, { + buffer = event.buf, + nowait = true, + desc = "Return to Dashboard" + }) + end) + end, }) diff --git a/lua/config/options.lua b/lua/config/options.lua index 6937b88..cae66cd 100644 --- a/lua/config/options.lua +++ b/lua/config/options.lua @@ -2,3 +2,8 @@ vim.opt.number = true vim.opt.cursorline = true vim.opt.relativenumber = true vim.opt.shiftwidth = 4 +-- disable netrw at the very start +vim.g.loaded_netrw = 1 +vim.g.loaded_netrwPlugin = 1 +vim.opt.splitbelow = true -- Opens horizontal splits below +vim.opt.splitright = true -- Opens vertical splits to the right diff --git a/lua/plugins/dashboard.lua b/lua/plugins/dashboard.lua index b45789c..0fc5ee8 100644 --- a/lua/plugins/dashboard.lua +++ b/lua/plugins/dashboard.lua @@ -19,7 +19,14 @@ return { header = vim.split(logo, "\n"), center = { -- Aligned to Mzansi Vim Essential Keybindings - { icon = "󰉓 ", desc = " File Explorer ", key = "cd", action = "Explore" }, + { + icon = "󰉓 ", + desc = " File Explorer ", + key = "cd", + action = function() + require("yazi").yazi(nil, vim.fn.getcwd()) + end + }, { icon = " ", desc = " Find Files ", key = "ff", action = "Telescope find_files" }, { icon = " ", desc = " Live Grep ", key = "fg", action = "Telescope live_grep" }, { diff --git a/lua/plugins/yazi.lua b/lua/plugins/yazi.lua new file mode 100644 index 0000000..c1fad7e --- /dev/null +++ b/lua/plugins/yazi.lua @@ -0,0 +1,29 @@ +return { + "mikavilpas/yazi.nvim", + event = "VeryLazy", + keys = { + -- Customize these keymaps to your liking! + { + "cd", + function() + require("yazi").yazi() + end, + desc = "Open yazi at the current file", + }, + { + -- Open in the current working directory + "cw", + function() + require("yazi").yazi(nil, vim.fn.getcwd()) + end, + desc = "Open yazi in cwd", + }, + }, + opts = { + -- if you want to replace netrw entirely with yazi + open_for_directories = true, + keymaps = { + show_help = "", + }, + }, +}