Skip to content

Commit

Permalink
chore: using mini.files, added plugins for vim-swap, `nvim-scissors…
Browse files Browse the repository at this point in the history
…` and `lazydo`
  • Loading branch information
shubham-cpp committed Jan 13, 2025
1 parent bb0de97 commit 8ed4636
Show file tree
Hide file tree
Showing 11 changed files with 230 additions and 40 deletions.
1 change: 1 addition & 0 deletions .config/ghostty/config
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
window-padding-color = background
font-family = "RecMonoDuotone Nerd Font"
font-feature = -liga
font-size = 11
theme = "catppuccin-mocha"

background =#0f0f11
Expand Down
8 changes: 5 additions & 3 deletions .config/nvim-lazy/lazy-lock.json
Original file line number Diff line number Diff line change
@@ -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" },
Expand Down Expand Up @@ -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" },
Expand All @@ -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" },
Expand All @@ -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" }
Expand Down
2 changes: 1 addition & 1 deletion .config/nvim-lazy/lua/plugins/ai/avante.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions .config/nvim-lazy/lua/plugins/disabled.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
}
11 changes: 6 additions & 5 deletions .config/nvim-lazy/lua/plugins/dooing.lua
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
---@type LazySpec
return {
'atiladefreitas/dooing',
keys = { '<leader>td' },
cmd = { 'Dooing' },
"atiladefreitas/dooing",
keys = { "<leader>td" },
enabled = false,
cmd = { "Dooing" },
opts = {
-- Keymaps
keymaps = {
toggle_window = '<leader>td',
toggle_window = "<leader>td",
},
},
config = function(_, opts)
require('dooing').setup(opts)
require("dooing").setup(opts)
end,
}
62 changes: 32 additions & 30 deletions .config/nvim-lazy/lua/plugins/fzf-lua.lua
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ return {
},
opts = {
defaults = {
formatter = { "path.filename_first", 2 },
keymap = {
fzf = {
["ctrl-d"] = "preview-page-down",
Expand All @@ -100,7 +101,6 @@ return {
},
},
files = {
formatter = "path.filename_first",
fzf_opts = {
["--layout"] = "reverse",
["--tiebreak"] = "length",
Expand Down Expand Up @@ -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,
},
}
2 changes: 1 addition & 1 deletion .config/nvim-lazy/lua/plugins/grapple.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
13 changes: 13 additions & 0 deletions .config/nvim-lazy/lua/plugins/lazydo.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---@type LazySpec
return {
'Dan7h3x/LazyDo',
keys = { -- recommended keymap for easy toggle LazyDo in normal and insert modes (arbitrary)
{
'<F2>',
'<CMD>LazyDoToggle<CR>',
mode = { 'n', 'i' },
desc = 'Toggle LazyDo',
},
},
opts = {},
}
136 changes: 136 additions & 0 deletions .config/nvim-lazy/lua/plugins/mini/files.lua
Original file line number Diff line number Diff line change
@@ -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 = {
{
"<leader>E",
minifiles_toggle,
desc = "Toggle file explorer",
},
{
"<leader>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, "<C-w>s", "horizontal", false)
map_split(buf_id, "<C-w>v", "vertical", false)
map_split(buf_id, "<C-w>S", "horizontal", true)
map_split(buf_id, "<C-w>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,
}
28 changes: 28 additions & 0 deletions .config/nvim-lazy/lua/plugins/nvim-scissors.lua
Original file line number Diff line number Diff line change
@@ -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 = {
{ '<leader>s', '', desc = '+[S]nippets' },
{
'<leader>se',
function()
require('scissors').editSnippet()
end,
desc = 'Snippet: [E]dit',
},
{
'<leader>sn',
function()
require('scissors').addNewSnippet()
end,
mode = { 'n', 'x' },
{ desc = 'Snippet: [N]ew' },
},
{ '<leader>sd', '<cmd>AutoSession delete<cr>', desc = '[D]elte' },
},
}
5 changes: 5 additions & 0 deletions .config/nvim-lazy/lua/plugins/vim-swap.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---@type LazySpec
return {
'machakann/vim-swap',
keys = { 'g>', 'g<' },
}

0 comments on commit 8ed4636

Please sign in to comment.