X-Git-Url: https://git.rmz.io/dotfiles.git/blobdiff_plain/4eda6b5272f7fe9b5fabb8e5c13ef4567004b865..HEAD:/nvim/lua/plugins/picker.lua diff --git a/nvim/lua/plugins/picker.lua b/nvim/lua/plugins/picker.lua index 36b5430..3878e03 100644 --- a/nvim/lua/plugins/picker.lua +++ b/nvim/lua/plugins/picker.lua @@ -1,23 +1,3 @@ -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", @@ -27,20 +7,11 @@ return { win = { input = { keys = { - [""] = { "toggle_cwd", mode = { "n", "i" }, }, [""] = { "trouble_open", 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, actions = require("trouble.sources.snacks").actions, }, }, @@ -48,18 +19,17 @@ return { -- stylua: ignore keys = { { ",", function() Snacks.picker.buffers() end, desc = "Buffers" }, - { "/", LazyVim.pick("grep"), desc = "Grep (Root Dir)" }, + { "/", function() Snacks.picker.grep() end, desc = "Grep" }, { ":", 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)" }, + { "fc", function() Snacks.picker.files({ cwd = vim.fn.stdpath("config") }) end, desc = "Find Config File" }, + { "fF", function() Snacks.picker.files() end, desc = "Find Files" }, { "fg", function() Snacks.picker.git_files() end, desc = "Find Files (git-files)" }, - { "fr", LazyVim.pick("oldfiles"), desc = "Recent" }, + -- TODO: swap fr and fR ? + { "fr", function() Snacks.picker.recent() end, desc = "Recent" }, { "fR", function() Snacks.picker.recent({ filter = { cwd = true }}) end, desc = "Recent (cwd)" }, { "fp", function() Snacks.picker.projects() end, desc = "Projects" }, -- git @@ -69,11 +39,9 @@ return { -- 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)" }, + { "sg", function() Snacks.picker.grep() end, desc = "Grep" }, { "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" } }, + { "sw", function() Snacks.picker.grep_word() end, desc = "Visual selection or word", mode = { "n", "x" } }, -- search { 's"', function() Snacks.picker.registers() end, desc = "Registers" }, { "sa", function() Snacks.picker.autocmds() end, desc = "Autocmds" }, @@ -97,15 +65,15 @@ return { }, { "neovim/nvim-lspconfig", opts = function() - local Keys = require("lazyvim.plugins.lsp.keymaps").get() + local Keys = require("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" }, + { "ss", function() Snacks.picker.lsp_symbols({ filter = rmz.lsp.kind_filter }) end, desc = "LSP Symbols", has = "documentSymbol" }, + { "sS", function() Snacks.picker.lsp_workspace_symbols({ filter = rmz.lsp.kind_filter }) end, desc = "LSP Workspace Symbols", has = "workspace/symbols" }, }) end, },