From fee20630b4cf3b0c71785c67760459d441ddee13 Mon Sep 17 00:00:00 2001 From: Zeioth Date: Sun, 4 Aug 2024 19:34:00 +0200 Subject: [PATCH 1/2] =?UTF-8?q?=E2=9C=A8feat(`yazi`):=20as=20drop-in=20rep?= =?UTF-8?q?lacement=20for=20`ranger`.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/base/health.lua | 10 ++------ lua/plugins/1-base-behaviors.lua | 44 ++++++++++---------------------- lua/plugins/2-ui.lua | 7 +---- 3 files changed, 17 insertions(+), 44 deletions(-) diff --git a/lua/base/health.lua b/lua/base/health.lua index 82fb96bf..0b3b9817 100644 --- a/lua/base/health.lua +++ b/lua/base/health.lua @@ -80,15 +80,9 @@ function M.check() msg = "Used for mappings to pull up git TUI (Optional)", }, { - cmd = { "pynvim" }, + cmd = { "yazi" }, type = "warn", - msg = - "Used to enable ranger file browser (optional)\nNOTE: checkhealth won't detect this correctly, but you can ensure it is installed with 'pip list | grep pynvim'.", - }, - { - cmd = { "ranger" }, - type = "warn", - msg = "Used to enable ranger file browser (Optional)", + msg = "Used to enable yazi file browser (Optional)", }, { cmd = { "delta" }, diff --git a/lua/plugins/1-base-behaviors.lua b/lua/plugins/1-base-behaviors.lua index 5758f16c..57867594 100644 --- a/lua/plugins/1-base-behaviors.lua +++ b/lua/plugins/1-base-behaviors.lua @@ -2,7 +2,7 @@ -- Things that add new behaviors. -- Sections: --- -> ranger file browser [ranger] +-- -> yazi file browser [yazi] -- -> project.nvim [project search + auto cd] -- -> trim.nvim [auto trim spaces] -- -> stickybuf.nvim [lock special buffers] @@ -24,39 +24,23 @@ -- -> nvim-lightbulb [lightbulb for code actions] -- -> distroupdate.nvim [distro update] -local is_windows = vim.fn.has('win32') == 1 -- true if on windows local is_android = vim.fn.isdirectory('/data') == 1 -- true if on android return { - -- [ranger] file browser - -- https://github.com/kevinhwang91/rnvimr - -- This is NormalNvim file browser, which is only for Linux. - -- - -- If you are on Windows, you have 3 options: - -- * Use neotree instead (+e). - -- * Delete rnvimr and install some other file browser you like. - -- * Or enable WLS on Windows and launch neovim from there. - -- This way you can install and use 'ranger' and its dependency 'pynvim'. + + -- [yazi] file browser + -- https://github.com/mikavilpas/yazi.nvim + -- Make sure you have yazi installed on your system! { - "kevinhwang91/rnvimr", + "mikavilpas/yazi.nvim", event = "User BaseDefered", - cmd = { "RnvimrToggle" }, - enabled = not is_windows, - config = function() - -- vim.g.rnvimr_vanilla = 1 -- Often solves issues in your ranger config. - vim.g.rnvimr_enable_picker = 1 -- Close rnvimr after choosing a file. - vim.g.rnvimr_ranger_cmd = { "ranger" } -- By passing a script like TERM=foot ranger "$@" you can open terminals inside ranger. - if is_android then -- Open on full screenn - vim.g.rnvimr_layout = { - relative = "editor", - width = 200, - height = 100, - col = 0, - row = 0, - style = "minimal", - } - end - end, + cmd = { "Yazi", "YaziCWD", "YaziToggle" }, + opts = { + open_for_directories = true, + use_ya_for_events_reading = true, + use_yazi_client_id_flag = true, + floating_window_scaling_factor = (is_android and 1.0) or 0.71 + }, }, -- project.nvim [project search + auto cd] @@ -146,7 +130,7 @@ return { event = "User BaseDefered", opts = { timeout = 300, - }, + } }, -- Toggle floating terminal on [term] diff --git a/lua/plugins/2-ui.lua b/lua/plugins/2-ui.lua index f7d31a2f..314b5dd1 100644 --- a/lua/plugins/2-ui.lua +++ b/lua/plugins/2-ui.lua @@ -150,15 +150,11 @@ return { dashboard.section.header.opts.hl = "DashboardHeader" vim.cmd "highlight DashboardHeader guifg=#F7778F" - -- If on windows, don't show the 'ranger' button - local ranger_button = dashboard.button("r", "🐍 Ranger ", "RnvimrToggle") - if is_windows then ranger_button = nil end - -- Buttons dashboard.section.buttons.val = { dashboard.button("n", "📄 New ", "ene"), dashboard.button("e", "🌺 Recent ", "Telescope oldfiles"), - ranger_button, + dashboard.button("r", "🦆 Yazi ", "Yazi"), dashboard.button( "s", "🔎 Sessions", @@ -566,7 +562,6 @@ return { }, config = function(_, opts) require("nvim-web-devicons").setup(opts) - pcall(vim.api.nvim_del_user_command, "NvimWebDeviconsHiTest") end }, From 45892f24ffe47158a9e01b4e842d824d84141e1e Mon Sep 17 00:00:00 2001 From: Zeioth Date: Sun, 4 Aug 2024 19:35:00 +0200 Subject: [PATCH 2/2] =?UTF-8?q?=E2=99=BB=EF=B8=8Frefactor(`parenthesis`):?= =?UTF-8?q?=20add=20where=20missing=20to=20keep=20style=20consistent.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/base/4-mappings.lua | 64 ++++++++++++++++++++------------------ lua/plugins/3-dev-core.lua | 5 +-- 2 files changed, 34 insertions(+), 35 deletions(-) diff --git a/lua/base/4-mappings.lua b/lua/base/4-mappings.lua index 001dc105..c4068b7e 100644 --- a/lua/base/4-mappings.lua +++ b/lua/base/4-mappings.lua @@ -92,7 +92,7 @@ maps.n["k"] = { "v:count == 0 ? 'gk' : 'k'", expr = true, desc = "Move cursor up" } maps.n["w"] = { "w", desc = "Save" } maps.n["W"] = -{ function() vim.cmd "SudaWrite" end, desc = "Save as sudo" } +{ function() vim.cmd("SudaWrite") end, desc = "Save as sudo" } maps.n["n"] = { "enew", desc = "New file" } maps.n["/"] = { "gcc", remap = true, desc = "Toggle comment line" } maps.x["/"] = { "gc", remap = true, desc = "Toggle comment" } @@ -194,8 +194,8 @@ maps.x["P"] = { "p", desc = "Yank what you are going to override, then paste" } -- to avoid triggering it by accident. maps.n[""] = { function() - if vim.fn.hlexists "Search" then - vim.cmd "nohlsearch" + if vim.fn.hlexists("Search") then + vim.cmd("nohlsearch") else vim.api.nvim_feedkeys( vim.api.nvim_replace_termcodes("", true, true, true), @@ -219,7 +219,7 @@ maps.n["gg"] = { if vim.v.count > 0 then vim.cmd("normal! " .. vim.v.count .. "gg") else - vim.cmd "normal! gg0" + vim.cmd("normal! gg0") end vim.g.minianimate_disable = false end, @@ -228,7 +228,7 @@ maps.n["gg"] = { maps.n["G"] = { function() vim.g.minianimate_disable = true - vim.cmd "normal! G$" + vim.cmd("normal! G$") vim.g.minianimate_disable = false end, desc = "G and go to the last position", @@ -239,7 +239,7 @@ maps.x["gg"] = { if vim.v.count > 0 then vim.cmd("normal! " .. vim.v.count .. "gg") else - vim.cmd "normal! gg0" + vim.cmd("normal! gg0") end vim.g.minianimate_disable = false end, @@ -248,7 +248,7 @@ maps.x["gg"] = { maps.x["G"] = { function() vim.g.minianimate_disable = true - vim.cmd "normal! G$" + vim.cmd("normal! G$") vim.g.minianimate_disable = false end, desc = "G and go to the last position (visual)", @@ -256,7 +256,7 @@ maps.x["G"] = { maps.n[""] = { -- to move to the previous position press ctrl + oo function() vim.g.minianimate_disable = true - vim.cmd "normal! gg0vG$" + vim.cmd("normal! gg0vG$") vim.g.minianimate_disable = false end, desc = "Visually select all", @@ -302,7 +302,7 @@ maps.n["C"] = { -- Close buffer keeping the window. -- desc = "Force close buffer", -- maps.n["ba"] = { - function() vim.cmd "wa" end, + function() vim.cmd("wa") end, desc = "Write all changed buffers", } maps.n["]b"] = { @@ -486,7 +486,7 @@ maps.n[""] = { local target_line = current_line + 1 + math.floor(total_lines * 0.20) if target_line > total_lines then target_line = total_lines end vim.api.nvim_win_set_cursor(0, { target_line, 0 }) - vim.cmd "normal! zz" + vim.cmd("normal! zz") end, desc = "Page down exactly a 20% of the total size of the buffer", } @@ -496,7 +496,7 @@ maps.n[""] = { local target_line = current_line - 1 - math.floor(vim.fn.line "$" * 0.20) if target_line < 1 then target_line = 1 end vim.api.nvim_win_set_cursor(0, { target_line, 0 }) - vim.cmd "normal! zz" + vim.cmd("normal! zz") end, desc = "Page up exactly 20% of the total size of the buffer", } @@ -626,7 +626,7 @@ end -- git fugitive if is_available "vim-fugitive" then maps.n["gP"] = { - function() vim.cmd ":GBrowse" end, + function() vim.cmd(":GBrowse") end, desc = "Open in github ", } end @@ -636,7 +636,7 @@ if vim.fn.executable "lazygit" == 1 then -- if lazygit exists, show it function() local git_dir = vim.fn.finddir(".git", vim.fn.getcwd() .. ";") if git_dir ~= "" then - vim.cmd "TermExec cmd='lazygit && exit'" + vim.cmd("TermExec cmd='lazygit && exit'") else utils.notify("Not a git repository", vim.log.levels.WARN) end @@ -650,9 +650,9 @@ if vim.fn.executable "gitui" == 1 then -- if gitui exists, show it local git_dir = vim.fn.finddir(".git", vim.fn.getcwd() .. ";") if git_dir ~= "" then if vim.fn.executable "keychain" == 1 then - vim.cmd 'TermExec cmd="eval `keychain --eval ~/.ssh/github.key` && gitui && exit"' + vim.cmd('TermExec cmd="eval `keychain --eval ~/.ssh/github.key` && gitui && exit"') else - vim.cmd "TermExec cmd='gitui && exit'" + vim.cmd("TermExec cmd='gitui && exit'") end else utils.notify("Not a git repository", vim.log.levels.WARN) @@ -663,9 +663,11 @@ if vim.fn.executable "gitui" == 1 then -- if gitui exists, show it end -- file browsers ------------------------------------ --- ranger -if is_available "rnvimr" then - maps.n["r"] = { "RnvimrToggle", desc = "Ranger" } +if is_available("yazi.nvim") then + maps.n["r"] = { + function() vim.cmd("YaziToggle") end, + desc = "File browser", + } end -- neotree @@ -960,7 +962,7 @@ if is_available "telescope.nvim" then -- extra - project.nvim if is_available "project.nvim" then maps.n["fp"] = { - function() vim.cmd "Telescope projects" end, + function() vim.cmd("Telescope projects") end, desc = "Find project", } end @@ -1010,27 +1012,27 @@ if is_available "telescope.nvim" then if is_available "compiler.nvim" and is_available "overseer.nvim" then maps.n["m"] = icons.c maps.n["mm"] = { - function() vim.cmd "CompilerOpen" end, + function() vim.cmdc"CompilerOpen") end, desc = "Open compiler", } maps.n["mr"] = { - function() vim.cmd "CompilerRedo" end, + function() vim.cmd("CompilerRedo") end, desc = "Compiler redo", } maps.n["mt"] = { - function() vim.cmd "CompilerToggleResults" end, + function() vim.cmd("CompilerToggleResults") end, desc = "compiler results", } maps.n[""] = { - function() vim.cmd "CompilerOpen" end, + function() vim.cmd("CompilerOpen") end, desc = "Open compiler", } maps.n[""] = { - function() vim.cmd "CompilerRedo" end, + function() vim.cmd("CompilerRedo") end, desc = "Compiler redo", } maps.n[""] = { - function() vim.cmd "CompilerToggleResults" end, + function() vim.cmd("CompilerToggleResults") end, desc = "compiler resume", } end @@ -1222,11 +1224,11 @@ end -- Extra - nodejs testing commands maps.n["Ta"] = { - function() vim.cmd "TestNodejs" end, + function() vim.cmd("TestNodejs") end, desc = "All", } maps.n["Te"] = { - function() vim.cmd "TestNodejsE2e" end, + function() vim.cmd("TestNodejsE2e") end, desc = "E2e", } @@ -1266,7 +1268,7 @@ if is_available "markdown-preview.nivm" or is_available "markmap.nvim" or is_ava -- Markdown preview if is_available "markdown-preview.nvim" then maps.n["Dp"] = { - function() vim.cmd "MarkdownPreview" end, + function() vim.cmd("MarkdownPreview") end, desc = "Markdown preview", } end @@ -1276,9 +1278,9 @@ if is_available "markdown-preview.nivm" or is_available "markmap.nvim" or is_ava maps.n["Dm"] = { function() if is_android then - vim.cmd "MarkmapWatch" + vim.cmd("MarkmapWatch") else - vim.cmd "MarkmapOpen" + vim.cmd("MarkmapOpen") end end, desc = "Markmap", @@ -1287,7 +1289,7 @@ if is_available "markdown-preview.nivm" or is_available "markmap.nvim" or is_ava if is_available "dooku.nvim" then maps.n["Dd"] = { - function() vim.cmd ":DookuGenerate" end, + function() vim.cmd(":DookuGenerate") end, desc = "Open documentation", } end diff --git a/lua/plugins/3-dev-core.lua b/lua/plugins/3-dev-core.lua index 01b15fd0..b6974df9 100644 --- a/lua/plugins/3-dev-core.lua +++ b/lua/plugins/3-dev-core.lua @@ -480,10 +480,7 @@ return { { path = "luvit-meta/library", mods = { "vim%.uv" } }, } end, - specs = { - { "Bilal2453/luvit-meta", lazy = true }, - -- { "folke/neodev.nvim", lazy = true} - }, + specs = { { "Bilal2453/luvit-meta", lazy = true } }, }, -- AUTO COMPLETION --------------------------------------------------------