]> git.rmz.io Git - dotfiles.git/blobdiff - nvim/lua/plugins/picker.lua
lazyvim: remove pick util
[dotfiles.git] / nvim / lua / plugins / picker.lua
index 36b543026ebf1c5f26f0fc29a129f051b765ed39..347804fb428cadb6212ecda647a106918b3f581f 100644 (file)
@@ -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 = {
-              ["<a-c>"] = { "toggle_cwd", mode = { "n", "i" }, },
               ["<c-t>"] = { "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 = {
       { "<leader>,", function() Snacks.picker.buffers() end, desc = "Buffers" },
-      { "<leader>/", LazyVim.pick("grep"), desc = "Grep (Root Dir)" },
+      { "<leader>/", function() Snacks.picker.grep() end, desc = "Grep" },
       { "<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>fc", function() Snacks.picker.files({ cwd = vim.fn.stdpath("config") }) end, desc = "Find Config File" },
+      { "<leader>fF", function() Snacks.picker.files() end, desc = "Find Files" },
       { "<leader>fg", function() Snacks.picker.git_files() end, desc = "Find Files (git-files)" },
-      { "<leader>fr", LazyVim.pick("oldfiles"), desc = "Recent" },
+      -- TODO: swap fr and fR ?
+      { "<leader>fr", function() Snacks.picker.recent() end, desc = "Recent" },
       { "<leader>fR", function() Snacks.picker.recent({ filter = { cwd = true }}) end, desc = "Recent (cwd)" },
       { "<leader>fp", function() Snacks.picker.projects() end, desc = "Projects" },
       -- git
@@ -69,11 +39,9 @@ return {
       -- 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)" },
+      { "<leader>sg", function() Snacks.picker.grep() end, desc = "Grep" },
       { "<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" } },
+      { "<leader>sw", function() Snacks.picker.grep_word() end, desc = "Visual selection or word", mode = { "n", "x" } },
       -- search
       { '<leader>s"', function() Snacks.picker.registers() end, desc = "Registers" },
       { "<leader>sa", function() Snacks.picker.autocmds() end, desc = "Autocmds" },