]> git.rmz.io Git - dotfiles.git/blobdiff - nvim/lua/plugins/snacks.lua
nvim/snacks: replace n with i in dashboard
[dotfiles.git] / nvim / lua / plugins / snacks.lua
index ae02a9bcb6395967e32daa18a3a4047964bf8a24..4b34734872bc3aaa28ee109c4c5bc5ac0245e8f5 100644 (file)
@@ -1,14 +1,81 @@
+-- Terminal Mappings
+local function term_nav(dir)
+  ---@param self snacks.terminal
+  return function(self)
+    return self:is_floating() and "<c-" .. dir .. ">" or vim.schedule(function()
+      vim.cmd.wincmd(dir)
+    end)
+  end
+end
+
 return {
   { "folke/snacks.nvim",
-    opts = {},
-    config = function(_, opts)
-      local notify = vim.notify
-      require("snacks").setup(opts)
-      -- HACK: restore vim.notify after snacks setup and let noice.nvim take over
-      -- this is needed to have early notifications show up in noice history
-      if LazyVim.has("noice.nvim") then
-        vim.notify = notify
-      end
-    end,
+    -- stylua: ignore
+    keys = {
+      -- Snacks Scratch
+      { "<leader>.",  function() Snacks.scratch() end, desc = "Toggle Scratch Buffer" },
+      { "<leader>S",  function() Snacks.scratch.select() end, desc = "Select Scratch Buffer" },
+      { "<leader>dps", function() Snacks.profiler.scratch() end, desc = "Profiler Scratch Buffer" },
+    },
+    opts = {
+      bigfile = { enabled = true },
+      indent = { enabled = true },
+      input = { enabled = true },  -- NOTE: seems unecessary
+      quickfile = { enabled = true },  -- TODO: review if needed
+      scope = { enabled = true },
+      scroll = { enabled = false },  -- fuck this!
+      statuscolumn = { enabled = true },
+      terminal = {
+        win = {
+          keys = {
+            nav_h = { "<C-h>", term_nav("W"), desc = "Go to Prev Window", expr = true, mode = "t" },
+            nav_j = { "<C-j>", term_nav("j"), desc = "Go to Lower Window", expr = true, mode = "t" },
+            nav_k = { "<C-k>", term_nav("k"), desc = "Go to Upper Window", expr = true, mode = "t" },
+            nav_l = { "<C-l>", term_nav("w"), desc = "Go to Next Window", expr = true, mode = "t" },
+          },
+        },
+      },
+      dashboard = {
+        preset = {
+          -- TODO: replace header
+          header = [[
+          ██╗      █████╗ ██╗   ██╗███████╗██╗   ██╗██╗   ██╗██╗███╗   ███╗          Z
+          ██║     ██╔══██╗██║   ██║╚══███╔╝╚██╗ ██╔╝██║   ██║██║████╗ ████║      Z    
+          ██║     ██║  ██║██║   ██║  ███╔╝  ╚████╔╝ ██║   ██║██║██╔████╔██║   z       
+          ██║     ██║  ██║██║   ██║ ███╔╝    ╚██╔╝  ╚██╗ ██╔╝██║██║╚██╔╝██║ z         
+          ███████╗╚█████╔╝╚██████╔╝███████╗   ██║    ╚████╔╝ ██║██║ ╚═╝ ██║           
+          ╚══════╝ ╚════╝  ╚═════╝ ╚══════╝   ╚═╝     ╚═══╝  ╚═╝╚═╝     ╚═╝           ]],
+          -- stylua: ignore
+          ---@type snacks.dashboard.Item[]
+          keys = {
+            { icon = " ", key = "f", desc = "Find File", action = ":lua Snacks.dashboard.pick('files')" },
+            { icon = " ", key = "i", desc = "New File", action = ":ene | startinsert" },
+            { icon = " ", key = "g", desc = "Find Text", action = ":lua Snacks.dashboard.pick('live_grep')" },
+            { icon = " ", key = "r", desc = "Recent Files", action = ":lua Snacks.dashboard.pick('oldfiles')" },
+            { icon = " ", key = "c", desc = "Config", action = ":lua Snacks.dashboard.pick('files', {cwd = vim.fn.stdpath('config')})" },
+            { icon = " ", key = "s", desc = "Restore Session", section = "session" },
+            { icon = " ", key = "x", desc = "Lazy Extras", action = ":LazyExtras" },
+            { icon = "󰒲 ", key = "l", desc = "Lazy", action = ":Lazy" },
+          },
+        },
+      },
+    },
+  },
+  { "folke/snacks.nvim",
+    opts = {
+      notifier = { enabled = true },
+    },
+    -- stylua: ignore
+    keys = {
+      -- TODO: review after picking picker (ha)
+      { "<leader>n", function()
+        if Snacks.config.picker and Snacks.config.picker.enabled then
+          Snacks.picker.notifications()
+        else
+          Snacks.notifier.show_history()
+        end
+      end, desc = "Notification History" },
+      { "<leader>un", function() Snacks.notifier.hide() end, desc = "Dismiss All Notifications" },
+    },
   }
 }