From 8ed4636c11385f3c033048d35dab6b55e0458570 Mon Sep 17 00:00:00 2001 From: Shubham Pawar Date: Mon, 13 Jan 2025 21:24:39 +0530 Subject: [PATCH] chore: using mini.files, added plugins for `vim-swap`, `nvim-scissors` and `lazydo` --- .config/ghostty/config | 1 + .config/nvim-lazy/lazy-lock.json | 8 +- .config/nvim-lazy/lua/plugins/ai/avante.lua | 2 +- .config/nvim-lazy/lua/plugins/disabled.lua | 2 + .config/nvim-lazy/lua/plugins/dooing.lua | 11 +- .config/nvim-lazy/lua/plugins/fzf-lua.lua | 62 ++++---- .config/nvim-lazy/lua/plugins/grapple.lua | 2 +- .config/nvim-lazy/lua/plugins/lazydo.lua | 13 ++ .config/nvim-lazy/lua/plugins/mini/files.lua | 136 ++++++++++++++++++ .../nvim-lazy/lua/plugins/nvim-scissors.lua | 28 ++++ .config/nvim-lazy/lua/plugins/vim-swap.lua | 5 + 11 files changed, 230 insertions(+), 40 deletions(-) create mode 100644 .config/nvim-lazy/lua/plugins/lazydo.lua create mode 100644 .config/nvim-lazy/lua/plugins/mini/files.lua create mode 100644 .config/nvim-lazy/lua/plugins/nvim-scissors.lua create mode 100644 .config/nvim-lazy/lua/plugins/vim-swap.lua diff --git a/.config/ghostty/config b/.config/ghostty/config index a87f56d..545b478 100644 --- a/.config/ghostty/config +++ b/.config/ghostty/config @@ -2,6 +2,7 @@ window-padding-color = background font-family = "RecMonoDuotone Nerd Font" font-feature = -liga +font-size = 11 theme = "catppuccin-mocha" background =#0f0f11 diff --git a/.config/nvim-lazy/lazy-lock.json b/.config/nvim-lazy/lazy-lock.json index 0edb676..a12247c 100644 --- a/.config/nvim-lazy/lazy-lock.json +++ b/.config/nvim-lazy/lazy-lock.json @@ -1,4 +1,5 @@ { + "LazyDo": { "branch": "main", "commit": "71c3c06f42c24e69df6c6d253cd3febbcbc87b81" }, "LazyVim": { "branch": "main", "commit": "d1529f650fdd89cb620258bdeca5ed7b558420c7" }, "LuaSnip": { "branch": "master", "commit": "c9b9a22904c97d0eb69ccb9bab76037838326817" }, "NeoTerm.lua": { "branch": "main", "commit": "f71a4a9663c52673a677a09894d945983c8da303" }, @@ -38,12 +39,13 @@ "mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" }, "mini.ai": { "branch": "main", "commit": "ebb04799794a7f94628153991e6334c3304961b8" }, "mini.align": { "branch": "main", "commit": "26111a737494bc39576ad67b52bbc2638ca23553" }, + "mini.files": { "branch": "main", "commit": "a3a9cce82115a69dba161ac45bda16f4e606f73b" }, "mini.icons": { "branch": "main", "commit": "1c79feb7478ca773fa3dac5cadf43ced9180e861" }, "mini.move": { "branch": "main", "commit": "4caa1c212f5ca3d1633d21cfb184808090ed74b1" }, "mini.operators": { "branch": "main", "commit": "35b12f54bd5acb860f4297fd6d12fd07b1b065e2" }, "mini.pairs": { "branch": "main", "commit": "7e834c5937d95364cc1740e20d673afe2d034cdb" }, "mini.surround": { "branch": "main", "commit": "aa5e245829dd12d8ff0c96ef11da28681d6049aa" }, - "neo-tree.nvim": { "branch": "main", "commit": "5185ab7d46f54322bf16d9ef7b1d34708302e2ab" }, + "neo-tree.nvim": { "branch": "main", "commit": "343886b020cb6bfbb326c4a07a7c356eb5ee05b7" }, "neogen": { "branch": "main", "commit": "dd0301bfba1f83a3bc009b5430fce7aa3cee6941" }, "neogit": { "branch": "master", "commit": "a1fc4e50fa494e04097cf2d02e86bcd7ac5760d6" }, "neotest": { "branch": "master", "commit": "d66cf4e05a116957f0d3a7755a24291c7d1e1f72" }, @@ -61,15 +63,14 @@ "nvim-dap-virtual-text": { "branch": "master", "commit": "df66808cd78b5a97576bbaeee95ed5ca385a9750" }, "nvim-highlight-colors": { "branch": "main", "commit": "68a4df620cf58e2c7336e53738e8cf3a522ad694" }, "nvim-lint": { "branch": "master", "commit": "dfa45de973c3ce7bd1b9a6d346f896a68ad07e44" }, - "nvim-lsp-file-operations": { "branch": "master", "commit": "9744b738183a5adca0f916527922078a965515ed" }, "nvim-lspconfig": { "branch": "master", "commit": "88157521e890fe7fdf18bee22438875edd6300a6" }, "nvim-nio": { "branch": "master", "commit": "a428f309119086dc78dd4b19306d2d67be884eee" }, + "nvim-scissors": { "branch": "main", "commit": "12d9f282b67525bb766c6fe33317caf25a19c86a" }, "nvim-snippets": { "branch": "main", "commit": "56b4052f71220144689caaa2e5b66222ba5661eb" }, "nvim-treesitter": { "branch": "master", "commit": "097fb77312c731347180e8907424f6c967323f05" }, "nvim-treesitter-context": { "branch": "master", "commit": "d0dd7ce5a9d0be1f28086e818e52fdc5c78975df" }, "nvim-treesitter-textobjects": { "branch": "master", "commit": "ad8f0a472148c3e0ae9851e26a722ee4e29b1595" }, "nvim-ts-autotag": { "branch": "main", "commit": "1cca23c9da708047922d3895a71032bc0449c52d" }, - "nvim-web-devicons": { "branch": "master", "commit": "aafa5c187a15701a7299a392b907ec15d9a7075f" }, "nvim-window-picker": { "branch": "main", "commit": "0031ae451fdbb928eafeb55ae7451232ebcc3438" }, "persistence.nvim": { "branch": "main", "commit": "f6aad7dde7fcf54148ccfc5f622c6d5badd0cc3d" }, "plenary.nvim": { "branch": "master", "commit": "3707cdb1e43f5cea73afb6037e6494e7ce847a66" }, @@ -90,6 +91,7 @@ "vim-dispatch": { "branch": "master", "commit": "a2ff28abdb2d89725192db5b8562977d392a4d3f" }, "vim-repeat": { "branch": "master", "commit": "65846025c15494983dafe5e3b46c8f88ab2e9635" }, "vim-subversive": { "branch": "master", "commit": "cea98a62ded4028118ad71c3e81b26eff2e0b8a0" }, + "vim-swap": { "branch": "master", "commit": "9358bfdc5e377aa13e7c2c2dd8699ba32b0dcf83" }, "vim-visual-multi": { "branch": "master", "commit": "a6975e7c1ee157615bbc80fc25e4392f71c344d4" }, "which-key.nvim": { "branch": "main", "commit": "1f8d414f61e0b05958c342df9b6a4c89ce268766" }, "yazi.nvim": { "branch": "main", "commit": "229e12bc1791a4050bf7e43f6b16608eeaf8d2a8" } diff --git a/.config/nvim-lazy/lua/plugins/ai/avante.lua b/.config/nvim-lazy/lua/plugins/ai/avante.lua index 485fe61..e131ecc 100644 --- a/.config/nvim-lazy/lua/plugins/ai/avante.lua +++ b/.config/nvim-lazy/lua/plugins/ai/avante.lua @@ -71,7 +71,7 @@ return { "nvim-lua/plenary.nvim", "MunifTanjim/nui.nvim", --- The below dependencies are optional, - "nvim-tree/nvim-web-devicons", -- or echasnovski/mini.icons + "echasnovski/mini.icons", { -- support for image pasting "HakonHarnes/img-clip.nvim", diff --git a/.config/nvim-lazy/lua/plugins/disabled.lua b/.config/nvim-lazy/lua/plugins/disabled.lua index cd16464..add58ef 100644 --- a/.config/nvim-lazy/lua/plugins/disabled.lua +++ b/.config/nvim-lazy/lua/plugins/disabled.lua @@ -3,4 +3,6 @@ return { { "dashboard-nvim", enabled = false }, { "folke/tokyonight.nvim", enabled = false }, { "folke/snacks.nvim", opts = { dashboard = { enabled = false } } }, + { "folke/snacks.nvim", opts = { dashboard = { enabled = false } } }, + { "neo-tree.nvim", enabled = false }, } diff --git a/.config/nvim-lazy/lua/plugins/dooing.lua b/.config/nvim-lazy/lua/plugins/dooing.lua index 1bc171b..156b091 100644 --- a/.config/nvim-lazy/lua/plugins/dooing.lua +++ b/.config/nvim-lazy/lua/plugins/dooing.lua @@ -1,15 +1,16 @@ ---@type LazySpec return { - 'atiladefreitas/dooing', - keys = { 'td' }, - cmd = { 'Dooing' }, + "atiladefreitas/dooing", + keys = { "td" }, + enabled = false, + cmd = { "Dooing" }, opts = { -- Keymaps keymaps = { - toggle_window = 'td', + toggle_window = "td", }, }, config = function(_, opts) - require('dooing').setup(opts) + require("dooing").setup(opts) end, } diff --git a/.config/nvim-lazy/lua/plugins/fzf-lua.lua b/.config/nvim-lazy/lua/plugins/fzf-lua.lua index faa5b98..04816e3 100644 --- a/.config/nvim-lazy/lua/plugins/fzf-lua.lua +++ b/.config/nvim-lazy/lua/plugins/fzf-lua.lua @@ -92,6 +92,7 @@ return { }, opts = { defaults = { + formatter = { "path.filename_first", 2 }, keymap = { fzf = { ["ctrl-d"] = "preview-page-down", @@ -100,7 +101,6 @@ return { }, }, files = { - formatter = "path.filename_first", fzf_opts = { ["--layout"] = "reverse", ["--tiebreak"] = "length", @@ -186,50 +186,52 @@ return { local fzf = require("fzf-lua") local config = fzf.config local actions = fzf.actions + local keys = { ["alt-enter"] = actions.file_tabedit, ["ctrl-t"] = actions.file_tabedit, ["ctrl-x"] = actions.file_split, ["ctrl-i"] = actions.toggle_ignore, } - - -- for _, value in pairs({ "files", "status", "bcommits", "commits" }) do - -- for key, binding in pairs(keys) do - -- config.defaults.actions.git[value][key] = binding - -- end - -- if LazyVim.has("trouble.nvim") then - -- config.defaults.actions.git[value]["ctrl-d"] = require("trouble.sources.fzf").actions.open - -- end - -- end - -- for _, value in pairs({ "declarations", "definitions", "references", "symbols" }) do - -- for key, binding in pairs(keys) do - -- config.defaults.actions.lsp[value][key] = binding - -- end - -- if LazyVim.has("trouble.nvim") then - -- config.defaults.actions.lsp[value]["ctrl-d"] = require("trouble.sources.fzf").actions.open - -- end - -- end + opts.git = opts.git or {} + for _, sub_map in pairs({ "files", "status", "bcommits", "commits" }) do + for key, binding in pairs(keys) do + opts.git[sub_map] = vim.tbl_deep_extend("force", opts.git[sub_map] or {}, { actions = { [key] = binding } }) + end + if LazyVim.has("trouble.nvim") then + opts.git[sub_map].actions["ctrl-d"] = require("trouble.sources.fzf").actions.open + end + end + opts.lsp = opts.lsp or {} + for _, sub_map in pairs({ "declarations", "definitions", "references", "symbols" }) do + for key, binding in pairs(keys) do + opts.lsp[sub_map] = vim.tbl_deep_extend("force", opts.lsp[sub_map] or {}, { actions = { [key] = binding } }) + end + if LazyVim.has("trouble.nvim") then + opts.lsp[sub_map].actions["ctrl-d"] = require("trouble.sources.fzf").actions.open + end + end for key, binding in pairs(keys) do - config.defaults.actions.files[key] = binding + opts.files = vim.tbl_deep_extend("force", opts.files, { actions = { [key] = binding } }) end - config.defaults.actions.files["alt-i"] = false - config.defaults.actions.files["alt-h"] = false if LazyVim.has("trouble.nvim") then - config.defaults.actions.files["ctrl-d"] = require("trouble.sources.fzf").actions.open + opts.files.actions["ctrl-d"] = require("trouble.sources.fzf").actions.open end + opts.files.actions["alt-i"] = false + opts.files.actions["alt-h"] = false + -- opts.buffers = opts.buffers or { actions = {} } -- for key, binding in pairs(keys) do - -- config.defaults.actions.buffers[key] = binding + -- opts.buffers.actions[key] = binding -- end - -- config.defaults.actions.buffers["ctrl-d"] = { fn = actions.buf_del, reload = true } + -- opts.buffers.actions["ctrl-d"] = { fn = actions.buf_del, reload = true } - -- for key, binding in pairs(keys) do - -- config.defaults.actions.grep[key] = binding - -- end - -- config.defaults.actions.grep["ctrl-g"] = actions.grep_lgrep - - return opts + opts.grep = opts.grep or { actions = {} } + for key, binding in pairs(keys) do + opts.grep.actions[key] = binding + end + opts.grep.actions["ctrl-g"] = actions.grep_lgrep end, }, } diff --git a/.config/nvim-lazy/lua/plugins/grapple.lua b/.config/nvim-lazy/lua/plugins/grapple.lua index d138a6a..8f2a4b6 100644 --- a/.config/nvim-lazy/lua/plugins/grapple.lua +++ b/.config/nvim-lazy/lua/plugins/grapple.lua @@ -3,7 +3,7 @@ return { "cbochs/grapple.nvim", enabled = true, dependencies = { - "nvim-tree/nvim-web-devicons", -- not strictly required, but recommended + "echasnovski/mini.icons", }, cmd = "Grapple", opts = { diff --git a/.config/nvim-lazy/lua/plugins/lazydo.lua b/.config/nvim-lazy/lua/plugins/lazydo.lua new file mode 100644 index 0000000..9922816 --- /dev/null +++ b/.config/nvim-lazy/lua/plugins/lazydo.lua @@ -0,0 +1,13 @@ +---@type LazySpec +return { + 'Dan7h3x/LazyDo', + keys = { -- recommended keymap for easy toggle LazyDo in normal and insert modes (arbitrary) + { + '', + 'LazyDoToggle', + mode = { 'n', 'i' }, + desc = 'Toggle LazyDo', + }, + }, + opts = {}, +} diff --git a/.config/nvim-lazy/lua/plugins/mini/files.lua b/.config/nvim-lazy/lua/plugins/mini/files.lua new file mode 100644 index 0000000..c992277 --- /dev/null +++ b/.config/nvim-lazy/lua/plugins/mini/files.lua @@ -0,0 +1,136 @@ +local au_group = vim.api.nvim_create_augroup("sp_mini", { clear = true }) + +local minifiles_toggle = function(...) + local f = require("mini.files") + local arg_len = ... == nil and 0 or #... + if not f.close() then + if arg_len == 0 then + f.open(f.get_latest_path()) + else + f.open(...) + end + end +end + +---@type LazySpec +return { + "echasnovski/mini.files", + version = "*", + enabled = true, + dependencies = { + "echasnovski/mini.icons", + { + "s1n7ax/nvim-window-picker", + version = "2.*", + config = function() + require("window-picker").setup({ + filter_rules = { + include_current_win = false, + autoselect_one = true, + -- filter using buffer options + bo = { + -- if the file type is one of following, the window will be ignored + filetype = { "neo-tree", "neo-tree-popup", "notify" }, + -- if the buffer type is one of following, the window will be ignored + buftype = { "terminal", "quickfix" }, + }, + }, + --- @type 'statusline-winbar' | 'floating-big-letter' + hint = "floating-big-letter", + }) + end, + }, + }, + keys = { + { + "E", + minifiles_toggle, + desc = "Toggle file explorer", + }, + { + "e", + function() + minifiles_toggle(vim.api.nvim_buf_get_name(0), false) + end, + desc = "Toggle file explorer(current file)", + }, + }, + config = function() + require("mini.files").setup({ + options = { + permanent_delete = false, + use_as_default_explorer = true, + }, + windows = { preview = true, width_preview = 45 }, + }) + + local map_split = function(buf_id, lhs, direction, close_on_file) + local rhs = function() + local new_target_window + local cur_target_window = require("mini.files").get_explorer_state().target_window + if cur_target_window ~= nil then + vim.api.nvim_win_call(cur_target_window, function() + vim.cmd("belowright " .. direction .. " split") + new_target_window = vim.api.nvim_get_current_win() + end) + + require("mini.files").set_target_window(new_target_window) + require("mini.files").go_in({ close_on_file = close_on_file }) + end + end + + local desc = "Open in " .. direction .. " split" + if close_on_file then + desc = desc .. " and close" + end + vim.keymap.set("n", lhs, rhs, { buffer = buf_id, desc = desc }) + end + local function open_in_window_picker() + local f = require("mini.files") + local fs_entry = f.get_fs_entry() + if fs_entry ~= nil and fs_entry.fs_type == "file" then + local picked_window_id = require("window-picker").pick_window() + if picked_window_id == nil then + return + end + f.set_target_window(picked_window_id) + end + f.go_in({ + close_on_file = true, + }) + end + vim.api.nvim_create_autocmd("User", { + pattern = "MiniFilesBufferCreate", + group = au_group, + desc = "Open in split(gs) or vsplit(gv)", + callback = function(args) + local buf_id = args.data.buf_id + + -- Tweak keys to your liking + map_split(buf_id, "gs", "horizontal", false) + map_split(buf_id, "gv", "vertical", false) + map_split(buf_id, "gS", "horizontal", true) + map_split(buf_id, "gV", "vertical", true) + + map_split(buf_id, "s", "horizontal", false) + map_split(buf_id, "v", "vertical", false) + map_split(buf_id, "S", "horizontal", true) + map_split(buf_id, "V", "vertical", true) + + vim.keymap.set("n", "gw", open_in_window_picker, { buffer = buf_id, desc = "Open in target window" }) + vim.keymap.set("n", "L", open_in_window_picker, { buffer = buf_id, desc = "Open in target window" }) + end, + }) + vim.api.nvim_create_autocmd("User", { + pattern = "MiniFilesActionRename", + group = au_group, + desc = "MiniFiles - LSP Rename file", + callback = function(event) + if not _G.Snacks then + return + end + Snacks.rename.on_rename_file(event.data.from, event.data.to) + end, + }) + end, +} diff --git a/.config/nvim-lazy/lua/plugins/nvim-scissors.lua b/.config/nvim-lazy/lua/plugins/nvim-scissors.lua new file mode 100644 index 0000000..669ced9 --- /dev/null +++ b/.config/nvim-lazy/lua/plugins/nvim-scissors.lua @@ -0,0 +1,28 @@ +---@type LazySpec +return { + 'chrisgrieser/nvim-scissors', + opts = { + snippetDir = vim.fn.stdpath 'config' .. '/snippets/', -- this is already the default, but I want to be explicit + ---@type "yq"|"jq"|"none"|string[] + jsonFormatter = vim.fn.executable 'jq' == 1 and 'jq' or 'none', + }, + keys = { + { 's', '', desc = '+[S]nippets' }, + { + 'se', + function() + require('scissors').editSnippet() + end, + desc = 'Snippet: [E]dit', + }, + { + 'sn', + function() + require('scissors').addNewSnippet() + end, + mode = { 'n', 'x' }, + { desc = 'Snippet: [N]ew' }, + }, + { 'sd', 'AutoSession delete', desc = '[D]elte' }, + }, +} diff --git a/.config/nvim-lazy/lua/plugins/vim-swap.lua b/.config/nvim-lazy/lua/plugins/vim-swap.lua new file mode 100644 index 0000000..482e18a --- /dev/null +++ b/.config/nvim-lazy/lua/plugins/vim-swap.lua @@ -0,0 +1,5 @@ +---@type LazySpec +return { + 'machakann/vim-swap', + keys = { 'g>', 'g<' }, +}