vim.g.lazyvim_picker = "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 ---@type LazySpec return { desc = "Fast and modern file picker", { "folke/snacks.nvim", opts = { picker = { win = { input = { keys = { [""] = { "trouble_open", mode = { "n", "i" }, }, }, }, }, actions = { actions = require("trouble.sources.snacks").actions, }, }, }, -- stylua: ignore keys = { { ",", function() Snacks.picker.buffers() end, desc = "Buffers" }, { "/", LazyVim.pick("grep"), desc = "Grep (Root Dir)" }, { ":", function() Snacks.picker.command_history() end, desc = "Command History" }, -- { "", LazyVim.pick("files"), desc = "Find Files (Root Dir)" }, { "n", function() Snacks.picker.notifications() end, desc = "Notification History" }, -- find { "fb", function() Snacks.picker.buffers() end, desc = "Buffers" }, { "fB", function() Snacks.picker.buffers({ hidden = true, nofile = true }) end, desc = "Buffers (all)" }, { "fc", LazyVim.pick.config_files(), desc = "Find Config File" }, -- { "ff", LazyVim.pick("files"), desc = "Find Files (Root Dir)" }, { "fF", LazyVim.pick("files", { root = false }), desc = "Find Files (cwd)" }, { "fg", function() Snacks.picker.git_files() end, desc = "Find Files (git-files)" }, { "fr", LazyVim.pick("oldfiles"), desc = "Recent" }, { "fR", function() Snacks.picker.recent({ filter = { cwd = true }}) end, desc = "Recent (cwd)" }, { "fp", function() Snacks.picker.projects() end, desc = "Projects" }, -- git -- { "gc", function() Snacks.picker.git_log() end, desc = "Git Log" }, -- { "gd", function() Snacks.picker.git_diff() end, desc = "Git Diff (hunks)" }, -- { "gs", function() Snacks.picker.git_status() end, desc = "Git Status" }, -- Grep { "sb", function() Snacks.picker.lines() end, desc = "Buffer Lines" }, { "sB", function() Snacks.picker.grep_buffers() end, desc = "Grep Open Buffers" }, { "sg", LazyVim.pick("live_grep"), desc = "Grep (Root Dir)" }, { "sG", LazyVim.pick("live_grep", { root = false }), desc = "Grep (cwd)" }, { "sp", function() Snacks.picker.lazy() end, desc = "Search for Plugin Spec" }, { "sw", LazyVim.pick("grep_word"), desc = "Visual selection or word (Root Dir)", mode = { "n", "x" } }, { "sW", LazyVim.pick("grep_word", { root = false }), desc = "Visual selection or word (cwd)", mode = { "n", "x" } }, -- search { 's"', function() Snacks.picker.registers() end, desc = "Registers" }, { "sa", function() Snacks.picker.autocmds() end, desc = "Autocmds" }, { "sc", function() Snacks.picker.command_history() end, desc = "Command History" }, { "sC", function() Snacks.picker.commands() end, desc = "Commands" }, { "sd", function() Snacks.picker.diagnostics() end, desc = "Diagnostics" }, { "sh", function() Snacks.picker.help() end, desc = "Help Pages" }, { "sH", function() Snacks.picker.highlights() end, desc = "Highlights" }, { "si", function() Snacks.picker.icons() end, desc = "Icons" }, { "sj", function() Snacks.picker.jumps() end, desc = "Jumps" }, { "sk", function() Snacks.picker.keymaps() end, desc = "Keymaps" }, { "sl", function() Snacks.picker.loclist() end, desc = "Location List" }, { "sM", function() Snacks.picker.man() end, desc = "Man Pages" }, { "sm", function() Snacks.picker.marks() end, desc = "Marks" }, { "sR", function() Snacks.picker.resume() end, desc = "Resume" }, { "sq", function() Snacks.picker.qflist() end, desc = "Quickfix List" }, { "su", function() Snacks.picker.undo() end, desc = "Undotree" }, -- ui { "uC", function() Snacks.picker.colorschemes() end, desc = "Colorschemes" }, }, }, { "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" }, { "ss", function() Snacks.picker.lsp_symbols({ filter = LazyVim.config.kind_filter }) end, desc = "LSP Symbols", has = "documentSymbol" }, { "sS", function() Snacks.picker.lsp_workspace_symbols({ filter = LazyVim.config.kind_filter }) end, desc = "LSP Workspace Symbols", has = "workspace/symbols" }, }) end, }, { "folke/todo-comments.nvim", optional = true, -- stylua: ignore keys = { { "st", function() Snacks.picker.todo_comments() end, desc = "Todo" }, { "sT", function () Snacks.picker.todo_comments({ keywords = { "TODO", "FIX", "FIXME" } }) end, desc = "Todo/Fix/Fixme" }, }, }, { "folke/flash.nvim", -- TODO: verify if I want to keep this specs = { { "folke/snacks.nvim", opts = { picker = { win = { input = { keys = { [""] = { "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, }, }, }, }, }, }, }