2025-01-14 22:54:12 +01:00
|
|
|
if lazyvim_docs then
|
|
|
|
-- In case you don't want to use `:LazyExtras`,
|
|
|
|
-- then you need to set the option below.
|
|
|
|
vim.g.lazyvim_picker = "snacks"
|
|
|
|
end
|
|
|
|
|
|
|
|
---@module 'snacks'
|
|
|
|
|
|
|
|
---@type LazyPicker
|
|
|
|
local picker = {
|
|
|
|
name = "snacks",
|
|
|
|
commands = {
|
|
|
|
files = "files",
|
|
|
|
live_grep = "grep",
|
|
|
|
oldfiles = "recent",
|
|
|
|
},
|
|
|
|
|
|
|
|
---@param source string
|
|
|
|
---@param opts? snacks.picker.Config
|
|
|
|
open = function(source, opts)
|
|
|
|
return Snacks.picker.pick(source, opts)
|
|
|
|
end,
|
|
|
|
}
|
|
|
|
if not LazyVim.pick.register(picker) then
|
|
|
|
return {}
|
|
|
|
end
|
|
|
|
|
|
|
|
return {
|
|
|
|
desc = "Fast and modern file picker",
|
2025-01-20 20:21:23 +01:00
|
|
|
recommended = true,
|
2025-01-14 22:54:12 +01:00
|
|
|
{
|
|
|
|
"folke/snacks.nvim",
|
|
|
|
opts = {
|
2025-01-20 20:21:23 +01:00
|
|
|
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,
|
|
|
|
},
|
|
|
|
},
|
2025-01-14 22:54:12 +01:00
|
|
|
},
|
|
|
|
-- stylua: ignore
|
|
|
|
keys = {
|
|
|
|
{ "<leader>,", function() Snacks.picker.buffers() end, desc = "Buffers" },
|
|
|
|
{ "<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)" },
|
2025-01-28 17:22:17 +01:00
|
|
|
{ "<leader>n", function() Snacks.picker.notifications() end, desc = "Notification History" },
|
2025-01-14 22:54:12 +01:00
|
|
|
-- find
|
|
|
|
{ "<leader>fb", function() Snacks.picker.buffers() end, desc = "Buffers" },
|
2025-01-23 19:22:47 +01:00
|
|
|
{ "<leader>fB", function() Snacks.picker.buffers({ hidden = true, nofile = true }) end, desc = "Buffers (all)" },
|
2025-01-14 22:54:12 +01:00
|
|
|
{ "<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" },
|
2025-01-28 19:55:02 +02:00
|
|
|
{ "<leader>fR", function() Snacks.picker.recent({ filter = { cwd = true }}) end, desc = "Recent (cwd)" },
|
2025-01-23 10:51:36 -05:00
|
|
|
{ "<leader>fp", function() Snacks.picker.projects() end, desc = "Projects" },
|
2025-01-14 22:54:12 +01:00
|
|
|
-- git
|
2025-01-16 09:58:28 +01:00
|
|
|
{ "<leader>gd", function() Snacks.picker.git_diff() end, desc = "Git Diff (hunks)" },
|
2025-01-14 22:54:12 +01:00
|
|
|
{ "<leader>gs", function() Snacks.picker.git_status() end, desc = "Git Status" },
|
2025-02-05 08:00:58 +01:00
|
|
|
{ "<leader>gS", function() Snacks.picker.git_stash() end, desc = "Git Stash" },
|
2025-01-14 22:54:12 +01:00
|
|
|
-- Grep
|
|
|
|
{ "<leader>sb", function() Snacks.picker.lines() end, desc = "Buffer Lines" },
|
|
|
|
{ "<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)" },
|
2025-01-23 19:22:19 +01:00
|
|
|
{ "<leader>sp", function() Snacks.picker.lazy() end, desc = "Search for Plugin Spec" },
|
2025-01-14 22:54:12 +01:00
|
|
|
{ "<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
|
|
|
|
{ '<leader>s"', function() Snacks.picker.registers() end, desc = "Registers" },
|
2025-02-05 08:00:58 +01:00
|
|
|
{ '<leader>s/', function() Snacks.picker.search_history() end, desc = "Search History" },
|
2025-01-14 22:54:12 +01:00
|
|
|
{ "<leader>sa", function() Snacks.picker.autocmds() end, desc = "Autocmds" },
|
|
|
|
{ "<leader>sc", function() Snacks.picker.command_history() end, desc = "Command History" },
|
|
|
|
{ "<leader>sC", function() Snacks.picker.commands() end, desc = "Commands" },
|
|
|
|
{ "<leader>sd", function() Snacks.picker.diagnostics() end, desc = "Diagnostics" },
|
2025-02-05 14:41:29 +01:00
|
|
|
{ "<leader>sD", function() Snacks.picker.diagnostics_buffer() end, desc = "Buffer Diagnostics" },
|
2025-01-14 22:54:12 +01:00
|
|
|
{ "<leader>sh", function() Snacks.picker.help() end, desc = "Help Pages" },
|
|
|
|
{ "<leader>sH", function() Snacks.picker.highlights() end, desc = "Highlights" },
|
2025-01-23 13:19:48 -05:00
|
|
|
{ "<leader>si", function() Snacks.picker.icons() end, desc = "Icons" },
|
2025-01-14 22:54:12 +01:00
|
|
|
{ "<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" },
|
|
|
|
{ "<leader>sM", function() Snacks.picker.man() end, desc = "Man Pages" },
|
|
|
|
{ "<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" },
|
2025-01-23 10:51:36 -05:00
|
|
|
{ "<leader>su", function() Snacks.picker.undo() end, desc = "Undotree" },
|
|
|
|
-- ui
|
2025-01-14 22:54:12 +01:00
|
|
|
{ "<leader>uC", function() Snacks.picker.colorschemes() end, desc = "Colorschemes" },
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"folke/snacks.nvim",
|
|
|
|
opts = function(_, opts)
|
|
|
|
if LazyVim.has("trouble.nvim") then
|
|
|
|
return vim.tbl_deep_extend("force", opts or {}, {
|
|
|
|
picker = {
|
2025-02-02 18:03:13 +01:00
|
|
|
actions = {
|
|
|
|
trouble_open = function(...)
|
|
|
|
return require("trouble.sources.snacks").actions.trouble_open.action(...)
|
|
|
|
end,
|
|
|
|
},
|
2025-01-14 22:54:12 +01:00
|
|
|
win = {
|
|
|
|
input = {
|
|
|
|
keys = {
|
2025-02-15 15:46:51 +01:00
|
|
|
["<a-t>"] = {
|
2025-01-14 22:54:12 +01:00
|
|
|
"trouble_open",
|
|
|
|
mode = { "n", "i" },
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
end
|
|
|
|
end,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"neovim/nvim-lspconfig",
|
|
|
|
opts = function()
|
|
|
|
local Keys = require("lazyvim.plugins.lsp.keymaps").get()
|
|
|
|
-- stylua: ignore
|
|
|
|
vim.list_extend(Keys, {
|
|
|
|
{ "gd", function() Snacks.picker.lsp_definitions() end, desc = "Goto Definition", has = "definition" },
|
|
|
|
{ "gr", function() Snacks.picker.lsp_references() end, nowait = true, desc = "References" },
|
|
|
|
{ "gI", function() Snacks.picker.lsp_implementations() end, desc = "Goto Implementation" },
|
|
|
|
{ "gy", function() Snacks.picker.lsp_type_definitions() end, desc = "Goto T[y]pe Definition" },
|
2025-01-16 18:37:59 +08:00
|
|
|
{ "<leader>ss", function() Snacks.picker.lsp_symbols({ filter = LazyVim.config.kind_filter }) end, desc = "LSP Symbols", has = "documentSymbol" },
|
2025-01-19 18:33:47 +01:00
|
|
|
{ "<leader>sS", function() Snacks.picker.lsp_workspace_symbols({ filter = LazyVim.config.kind_filter }) end, desc = "LSP Workspace Symbols", has = "workspace/symbols" },
|
2025-01-14 22:54:12 +01:00
|
|
|
})
|
|
|
|
end,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"folke/todo-comments.nvim",
|
|
|
|
optional = true,
|
|
|
|
-- stylua: ignore
|
|
|
|
keys = {
|
|
|
|
{ "<leader>st", function() Snacks.picker.todo_comments() end, desc = "Todo" },
|
|
|
|
{ "<leader>sT", function () Snacks.picker.todo_comments({ keywords = { "TODO", "FIX", "FIXME" } }) end, desc = "Todo/Fix/Fixme" },
|
|
|
|
},
|
|
|
|
},
|
2025-02-08 15:27:20 +01:00
|
|
|
{
|
|
|
|
"folke/snacks.nvim",
|
|
|
|
opts = function(_, opts)
|
|
|
|
table.insert(opts.dashboard.preset.keys, 3, {
|
|
|
|
icon = " ",
|
|
|
|
key = "p",
|
|
|
|
desc = "Projects",
|
|
|
|
action = ":lua Snacks.picker.projects()",
|
|
|
|
})
|
|
|
|
end,
|
|
|
|
},
|
2025-02-15 15:30:45 +08:00
|
|
|
{
|
|
|
|
"goolord/alpha-nvim",
|
|
|
|
optional = true,
|
|
|
|
opts = function(_, dashboard)
|
|
|
|
local button = dashboard.button("p", " " .. " Projects", [[<cmd> lua Snacks.picker.projects() <cr>]])
|
|
|
|
button.opts.hl = "AlphaButtons"
|
|
|
|
button.opts.hl_shortcut = "AlphaShortcut"
|
|
|
|
table.insert(dashboard.section.buttons.val, 4, button)
|
|
|
|
end,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"echasnovski/mini.starter",
|
|
|
|
optional = true,
|
|
|
|
opts = function(_, opts)
|
|
|
|
local items = {
|
|
|
|
{
|
|
|
|
name = "Projects",
|
|
|
|
action = [[lua Snacks.picker.projects()]],
|
|
|
|
section = string.rep(" ", 22) .. "Telescope",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
vim.list_extend(opts.items, items)
|
|
|
|
end,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"nvimdev/dashboard-nvim",
|
|
|
|
optional = true,
|
|
|
|
opts = function(_, opts)
|
|
|
|
if not vim.tbl_get(opts, "config", "center") then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
local projects = {
|
|
|
|
action = "lua Snacks.picker.projects()",
|
|
|
|
desc = " Projects",
|
|
|
|
icon = " ",
|
|
|
|
key = "p",
|
|
|
|
}
|
|
|
|
|
|
|
|
projects.desc = projects.desc .. string.rep(" ", 43 - #projects.desc)
|
|
|
|
projects.key_format = " %s"
|
|
|
|
|
|
|
|
table.insert(opts.config.center, 3, projects)
|
|
|
|
end,
|
|
|
|
},
|
2025-01-29 20:18:43 +01:00
|
|
|
{
|
2025-01-29 21:06:36 +01:00
|
|
|
"folke/flash.nvim",
|
2025-01-29 20:18:43 +01:00
|
|
|
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])
|
2025-01-29 23:21:59 +01:00
|
|
|
picker.list:_move(idx, true, true)
|
2025-01-29 20:18:43 +01:00
|
|
|
end,
|
|
|
|
})
|
|
|
|
end,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2025-01-14 22:54:12 +01:00
|
|
|
}
|