mirror of
https://github.com/LazyVim/LazyVim.git
synced 2025-08-16 15:31:06 +02:00
Merge branch 'main' into mini.files-windowpicker
This commit is contained in:
commit
3cdf8d31a5
14 changed files with 315 additions and 15 deletions
25
lua/lazyvim/plugins/extras/editor/snacks_explorer.lua
Normal file
25
lua/lazyvim/plugins/extras/editor/snacks_explorer.lua
Normal file
|
@ -0,0 +1,25 @@
|
|||
return {
|
||||
{ "nvim-neo-tree/neo-tree.nvim", enabled = false },
|
||||
{
|
||||
"folke/snacks.nvim",
|
||||
opts = { explorer = {} },
|
||||
keys = {
|
||||
{
|
||||
"<leader>fe",
|
||||
function()
|
||||
Snacks.explorer({ cwd = LazyVim.root() })
|
||||
end,
|
||||
desc = "Explorer Snacks (root dir)",
|
||||
},
|
||||
{
|
||||
"<leader>fE",
|
||||
function()
|
||||
Snacks.explorer()
|
||||
end,
|
||||
desc = "Explorer Snacks (cwd)",
|
||||
},
|
||||
{ "<leader>e", "<leader>fe", desc = "Explorer Snacks (root dir)", remap = true },
|
||||
{ "<leader>E", "<leader>fE", desc = "Explorer Snacks (cwd)", remap = true },
|
||||
},
|
||||
},
|
||||
}
|
|
@ -27,11 +27,32 @@ end
|
|||
|
||||
return {
|
||||
desc = "Fast and modern file picker",
|
||||
-- recommended = true,
|
||||
recommended = true,
|
||||
{
|
||||
"folke/snacks.nvim",
|
||||
opts = {
|
||||
picker = {},
|
||||
picker = {
|
||||
win = {
|
||||
input = {
|
||||
keys = {
|
||||
["<a-c>"] = {
|
||||
"toggle_cwd",
|
||||
mode = { "n", "i" },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
actions = {
|
||||
---@param p snacks.Picker
|
||||
toggle_cwd = function(p)
|
||||
local root = LazyVim.root({ buf = p.input.filter.current_buf, normalize = true })
|
||||
local cwd = vim.fs.normalize((vim.uv or vim.loop).cwd() or ".")
|
||||
local current = p:cwd()
|
||||
p:set_cwd(current == root and cwd or root)
|
||||
p:find()
|
||||
end,
|
||||
},
|
||||
},
|
||||
},
|
||||
-- stylua: ignore
|
||||
keys = {
|
||||
|
@ -39,14 +60,17 @@ return {
|
|||
{ "<leader>/", LazyVim.pick("grep"), desc = "Grep (Root Dir)" },
|
||||
{ "<leader>:", function() Snacks.picker.command_history() end, desc = "Command History" },
|
||||
{ "<leader><space>", LazyVim.pick("files"), desc = "Find Files (Root Dir)" },
|
||||
{ "<leader>n", function() Snacks.picker.notifications() end, desc = "Notification History" },
|
||||
-- find
|
||||
{ "<leader>fb", function() Snacks.picker.buffers() end, desc = "Buffers" },
|
||||
{ "<leader>fB", function() Snacks.picker.buffers({ hidden = true, nofile = true }) end, desc = "Buffers (all)" },
|
||||
{ "<leader>fc", LazyVim.pick.config_files(), desc = "Find Config File" },
|
||||
{ "<leader>ff", LazyVim.pick("files"), desc = "Find Files (Root Dir)" },
|
||||
{ "<leader>fF", LazyVim.pick("files", { root = false }), desc = "Find Files (cwd)" },
|
||||
{ "<leader>fg", function() Snacks.picker.git_files() end, desc = "Find Files (git-files)" },
|
||||
{ "<leader>fr", LazyVim.pick("oldfiles"), desc = "Recent" },
|
||||
{ "<leader>fR", LazyVim.pick("oldfiles", { filter = { cwd = true }}), desc = "Recent (cwd)" },
|
||||
{ "<leader>fR", function() Snacks.picker.recent({ filter = { cwd = true }}) end, desc = "Recent (cwd)" },
|
||||
{ "<leader>fp", function() Snacks.picker.projects() end, desc = "Projects" },
|
||||
-- git
|
||||
{ "<leader>gc", function() Snacks.picker.git_log() end, desc = "Git Log" },
|
||||
{ "<leader>gd", function() Snacks.picker.git_diff() end, desc = "Git Diff (hunks)" },
|
||||
|
@ -56,6 +80,7 @@ return {
|
|||
{ "<leader>sB", function() Snacks.picker.grep_buffers() end, desc = "Grep Open Buffers" },
|
||||
{ "<leader>sg", LazyVim.pick("live_grep"), desc = "Grep (Root Dir)" },
|
||||
{ "<leader>sG", LazyVim.pick("live_grep", { root = false }), desc = "Grep (cwd)" },
|
||||
{ "<leader>sp", function() Snacks.picker.lazy() end, desc = "Search for Plugin Spec" },
|
||||
{ "<leader>sw", LazyVim.pick("grep_word"), desc = "Visual selection or word (Root Dir)", mode = { "n", "x" } },
|
||||
{ "<leader>sW", LazyVim.pick("grep_word", { root = false }), desc = "Visual selection or word (cwd)", mode = { "n", "x" } },
|
||||
-- search
|
||||
|
@ -66,6 +91,7 @@ return {
|
|||
{ "<leader>sd", function() Snacks.picker.diagnostics() end, desc = "Diagnostics" },
|
||||
{ "<leader>sh", function() Snacks.picker.help() end, desc = "Help Pages" },
|
||||
{ "<leader>sH", function() Snacks.picker.highlights() end, desc = "Highlights" },
|
||||
{ "<leader>si", function() Snacks.picker.icons() end, desc = "Icons" },
|
||||
{ "<leader>sj", function() Snacks.picker.jumps() end, desc = "Jumps" },
|
||||
{ "<leader>sk", function() Snacks.picker.keymaps() end, desc = "Keymaps" },
|
||||
{ "<leader>sl", function() Snacks.picker.loclist() end, desc = "Location List" },
|
||||
|
@ -73,8 +99,9 @@ return {
|
|||
{ "<leader>sm", function() Snacks.picker.marks() end, desc = "Marks" },
|
||||
{ "<leader>sR", function() Snacks.picker.resume() end, desc = "Resume" },
|
||||
{ "<leader>sq", function() Snacks.picker.qflist() end, desc = "Quickfix List" },
|
||||
{ "<leader>su", function() Snacks.picker.undo() end, desc = "Undotree" },
|
||||
-- ui
|
||||
{ "<leader>uC", function() Snacks.picker.colorschemes() end, desc = "Colorschemes" },
|
||||
{ "<leader>fp", function() Snacks.picker.projects() end, desc = "Projects" },
|
||||
},
|
||||
},
|
||||
{
|
||||
|
@ -126,4 +153,45 @@ return {
|
|||
{ "<leader>sT", function () Snacks.picker.todo_comments({ keywords = { "TODO", "FIX", "FIXME" } }) end, desc = "Todo/Fix/Fixme" },
|
||||
},
|
||||
},
|
||||
{
|
||||
"folke/flash.nvim",
|
||||
optional = true,
|
||||
specs = {
|
||||
{
|
||||
"folke/snacks.nvim",
|
||||
opts = {
|
||||
picker = {
|
||||
win = {
|
||||
input = {
|
||||
keys = {
|
||||
["<a-s>"] = { "flash", mode = { "n", "i" } },
|
||||
["s"] = { "flash" },
|
||||
},
|
||||
},
|
||||
},
|
||||
actions = {
|
||||
flash = function(picker)
|
||||
require("flash").jump({
|
||||
pattern = "^",
|
||||
label = { after = { 0, 0 } },
|
||||
search = {
|
||||
mode = "search",
|
||||
exclude = {
|
||||
function(win)
|
||||
return vim.bo[vim.api.nvim_win_get_buf(win)].filetype ~= "snacks_picker_list"
|
||||
end,
|
||||
},
|
||||
},
|
||||
action = function(match)
|
||||
local idx = picker.list:row2idx(match.pos[1])
|
||||
picker.list:_move(idx, true, true)
|
||||
end,
|
||||
})
|
||||
end,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue