From bb6936d7465a9e4edca7c979d9763a9e9ad34e6a Mon Sep 17 00:00:00 2001
From: Gustaf Rydholm <gustaf.rydholm@gmail.com>
Date: Mon, 8 Aug 2022 16:12:22 +0200
Subject: Add harpoon

---
 fnl/config/harpoon.fnl   | 18 ++++++++++++++++++
 fnl/config/init.fnl      |  1 +
 fnl/config/minibar.fnl   |  1 +
 fnl/config/telescope.fnl |  1 +
 fnl/config/which-key.fnl | 20 +++++++++++++++++---
 fnl/plugins.fnl          |  1 +
 6 files changed, 39 insertions(+), 3 deletions(-)
 create mode 100644 fnl/config/harpoon.fnl

diff --git a/fnl/config/harpoon.fnl b/fnl/config/harpoon.fnl
new file mode 100644
index 0000000..0c3ca5e
--- /dev/null
+++ b/fnl/config/harpoon.fnl
@@ -0,0 +1,18 @@
+;; Harpoon files for navigation.
+(module config.harpoon {autoload {: util nvim aniseed.nvim}})
+
+(def- opts {})
+
+(util.use-config :harpoon opts)
+(nvim.set_keymap
+  "n"
+  "<tab>"
+  "<cmd>lua require('telescope').extensions.harpoon.marks(require('telescope.themes').get_dropdown{previewer = false, initial_mode='normal', prompt_title='Harpoon'})<cr>"
+  opts
+)
+(nvim.set_keymap
+  "n"
+  "<s-tab>"
+  "<cmd>lua require('telescope.builtin').buffers(require('telescope.themes').get_dropdown{previewer = false, initial_mode='normal'})<cr>"
+  opts
+)
diff --git a/fnl/config/init.fnl b/fnl/config/init.fnl
index a6b0dcf..fb1d95b 100644
--- a/fnl/config/init.fnl
+++ b/fnl/config/init.fnl
@@ -12,6 +12,7 @@
                               config.comment
                               config.fidget
                               config.gitsigns
+                              config.harpoon
                               config.hop
                               config.lir
                               config.lsp
diff --git a/fnl/config/minibar.fnl b/fnl/config/minibar.fnl
index 0d301e7..09e97b4 100644
--- a/fnl/config/minibar.fnl
+++ b/fnl/config/minibar.fnl
@@ -2,6 +2,7 @@
 
 (def- opts {:ignore-filetypes [:help
                                :startify
+                               :harpoon
                                :dashboard
                                :packer
                                :neogitstatus
diff --git a/fnl/config/telescope.fnl b/fnl/config/telescope.fnl
index a53433d..7989c54 100644
--- a/fnl/config/telescope.fnl
+++ b/fnl/config/telescope.fnl
@@ -78,4 +78,5 @@
     (telescope.load_extension :fzf)
     (telescope.load_extension :file_browser)
     (telescope.load_extension :session-lens)
+    (telescope.load_extension :harpoon)
     (telescope.load_extension :projects)))
diff --git a/fnl/config/which-key.fnl b/fnl/config/which-key.fnl
index 9f3d31b..13c6ebc 100644
--- a/fnl/config/which-key.fnl
+++ b/fnl/config/which-key.fnl
@@ -28,14 +28,20 @@
              :triggers :auto
              :triggers_blacklist {:i [:j :k] :v [:j :k]}})
 
-(def- nopts {:mode :n
-             :prefix :<leader>
+(def- mopts {:mode :n
+             :prefix :m
              :buffer nil
              :silent true
              :noremap true
              :nowait true})
 
-(def- vopts {:mode :v
+(def- mmappings {:a ["<cmd>lua require('harpoon.mark').add_file()<cr>" "Harpoon"]
+                 :l ["<cmd>lua require('harpoon.ui').nav_next()<cr>" "Harpoon Next"]
+                 :h ["<cmd>lua require('harpoon.ui').nav_prev()<cr>" "Harpoon Prev"]
+                 :t ["<cmd>Telescope harpoon marks<cr>" "Search Files"]
+                 :r ["<cmd>lua require('harpoon.ui').toggle_quick_menu()<cr>" "Harpoon UI"]})
+
+(def- nopts {:mode :n
              :prefix :<leader>
              :buffer nil
              :silent true
@@ -142,10 +148,18 @@
                  :T treesitter
                  :z [:<cmd>ZenMode<cr> "Zen Mode"]})
 
+(def- vopts {:mode :v
+             :prefix :<leader>
+             :buffer nil
+             :silent true
+             :noremap true
+             :nowait true})
+
 (def- vmappings {:n ["<ESC><CMD>lua require('Comment.api').toggle_linewise_op(vim.fn.visualmode())<CR>"
                      :Comment]})
 
 (let [which-key (util.load-plugin :which-key)]
   (which-key.setup setup)
+  (which-key.register mmappings mopts)
   (which-key.register nmappings nopts)
   (which-key.register vmappings vopts))
diff --git a/fnl/plugins.fnl b/fnl/plugins.fnl
index 070c16c..b3aa735 100644
--- a/fnl/plugins.fnl
+++ b/fnl/plugins.fnl
@@ -16,6 +16,7 @@
  :antoinemadec/FixCursorHold.nvim {}
  :rafamadriz/friendly-snippets {}
  :lewis6991/gitsigns.nvim {}
+ :ThePrimeagen/harpoon {}
  :phaazon/hop.nvim {}
  :lewis6991/impatient.nvim {}
  :tamago324/lir.nvim {}
-- 
cgit v1.2.3-70-g09d2