diff --git a/lua/astrocommunity/fuzzy-finder/snacks-picker/README.md b/lua/astrocommunity/fuzzy-finder/snacks-picker/README.md new file mode 100644 index 000000000..d533e50d5 --- /dev/null +++ b/lua/astrocommunity/fuzzy-finder/snacks-picker/README.md @@ -0,0 +1,5 @@ +# snacks.picker + +Snacks now comes with a modern fuzzy-finder to navigate the Neovim universe. + +**Repository:** diff --git a/lua/astrocommunity/fuzzy-finder/snacks-picker/init.lua b/lua/astrocommunity/fuzzy-finder/snacks-picker/init.lua new file mode 100644 index 000000000..a66b760e3 --- /dev/null +++ b/lua/astrocommunity/fuzzy-finder/snacks-picker/init.lua @@ -0,0 +1,114 @@ +return { + "folke/snacks.nvim", + priority = 1000, + lazy = false, + dependencies = { "nvim-treesitter/nvim-treesitter" }, + opts = { picker = { ui_select = true } }, + specs = { + { + "AstroNvim/astrocore", + opts = function(_, opts) + local maps = opts.mappings + maps.n["f"] = vim.tbl_get(opts, "_map_sections", "f") + if vim.fn.executable "git" == 1 then + maps.n["g"] = vim.tbl_get(opts, "_map_sections", "g") + maps.n["gb"] = { function() require("snacks").picker.git_branches() end, desc = "Git branches" } + maps.n["gc"] = { + function() require("snacks").picker.git_log() end, + desc = "Git commits (repository)", + } + maps.n["gC"] = { + function() require("snacks").picker.git_log { current_file = true, follow = true } end, + desc = "Git commits (current file)", + } + maps.n["gt"] = { function() require("snacks").picker.git_status() end, desc = "Git status" } + end + maps.n["f"] = { function() require("snacks").picker.resume() end, desc = "Resume previous search" } + maps.n["f'"] = { function() require("snacks").picker.marks() end, desc = "Find marks" } + maps.n["fl"] = { + function() require("snacks").picker.lines() end, + desc = "Find lines", + } + maps.n["fa"] = { + function() require("snacks").picker.files { cwd = vim.fn.stdpath "config", desc = "Config Files" } end, + desc = "Find AstroNvim config files", + } + maps.n["fb"] = { function() require("snacks").picker.buffers() end, desc = "Find buffers" } + maps.n["fc"] = { function() require("snacks").picker.grep_word() end, desc = "Find word under cursor" } + maps.n["fC"] = { function() require("snacks").picker.commands() end, desc = "Find commands" } + maps.n["ff"] = { + function() + require("snacks").picker.files { + hidden = vim.tbl_get((vim.uv or vim.loop).fs_stat ".git" or {}, "type") == "directory", + } + end, + desc = "Find files", + } + maps.n["fF"] = { + function() require("snacks").picker.files { hidden = true, ignored = true } end, + desc = "Find all files", + } + maps.n["fg"] = { function() require("snacks").picker.git_files() end, desc = "Find git files" } + maps.n["fh"] = { function() require("snacks").picker.help() end, desc = "Find help" } + maps.n["fk"] = { function() require("snacks").picker.keymaps() end, desc = "Find keymaps" } + maps.n["fm"] = { function() require("snacks").picker.man() end, desc = "Find man" } + maps.n["fo"] = { function() require("snacks").picker.recent() end, desc = "Find old files" } + maps.n["fO"] = + { function() require("snacks").picker.recent { cwd = true } end, desc = "Find old files (cwd)" } + maps.n["fr"] = { function() require("snacks").picker.registers() end, desc = "Find registers" } + maps.n["fs"] = { function() require("snacks").picker.smart() end, desc = "Find buffers/recent/files" } + maps.n["ft"] = { function() require("snacks").picker.colorschemes() end, desc = "Find themes" } + if vim.fn.executable "rg" == 1 then + maps.n["fw"] = { function() require("snacks").picker.grep() end, desc = "Find words" } + maps.n["fW"] = { + function() require("snacks").picker.grep { hidden = true, ignored = true } end, + desc = "Find words in all files", + } + end + maps.n["lD"] = { function() require("snacks").picker.diagnostics() end, desc = "Search diagnostics" } + maps.n["ls"] = { function() require("snacks").picker.lsp_symbols() end, desc = "Search symbols" } + end, + }, + { + "folke/todo-comments.nvim", + optional = true, + dependencies = { "folke/snacks.nvim" }, + specs = { + { + "AstroNvim/astrocore", + opts = { + mappings = { + n = { + ["fT"] = { + function() + if not package.loaded["todo-comments"] then -- make sure to load todo-comments + require("lazy").load { plugins = { "todo-comments.nvim" } } + end + require("snacks").picker.todo_comments() + end, + desc = "Todo Comments", + }, + }, + }, + }, + }, + }, + }, + { + "nvim-neo-tree/neo-tree.nvim", + optional = true, + opts = { + commands = { + find_in_dir = function(state) + local node = state.tree:get_node() + local path = node.type == "file" and node:get_parent_id() or node:get_id() + require("snacks").picker.files { cwd = path } + end, + }, + window = { mappings = { F = "find_in_dir" } }, + }, + }, + { "nvim-telescope/telescope.nvim", enabled = false }, + { "stevearc/dressing.nvim", opts = { select = { enabled = false } } }, + }, +}