-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: using mini.files, added plugins for
vim-swap
, `nvim-scissors…
…` and `lazydo`
- Loading branch information
1 parent
bb0de97
commit 8ed4636
Showing
11 changed files
with
230 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = {}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' }, | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
---@type LazySpec | ||
return { | ||
'machakann/vim-swap', | ||
keys = { 'g>', 'g<' }, | ||
} |