From 0586c7a92cc352925e0e60009dd4ec975880748c Mon Sep 17 00:00:00 2001 From: Ariel D'Alessandro Date: Fri, 13 Jan 2023 10:43:22 +0100 Subject: feat: move harpoon to lazy load --- lua/alpha/harpoon.lua | 44 ++++++++++++++++++++++++++++++++++++++++++++ lua/alpha/plugins.lua | 4 ++++ 2 files changed, 48 insertions(+) create mode 100644 lua/alpha/harpoon.lua (limited to 'lua') diff --git a/lua/alpha/harpoon.lua b/lua/alpha/harpoon.lua new file mode 100644 index 0000000..958489b --- /dev/null +++ b/lua/alpha/harpoon.lua @@ -0,0 +1,44 @@ +local M = {}; + +-- changing this values will require re-compile packer +local terms = vim.g.harpoon_terms or 3 +local quick_binds = vim.g.harpoon_quick_binds or 5 + +M.keymaps = { + "ss", + "sa", +} + +for i = 1, terms do + table.insert(M.keymaps, string.format("%s", i)) +end + +for i = 1, quick_binds do + table.insert(M.keymaps, string.format("%s", i)) +end + +M.setup = function() + require('harpoon').setup({}) + + vim.keymap.set('n', 'ss', require("harpoon.ui").toggle_quick_menu, + { noremap = true, silent = true, expr = false }) + vim.keymap.set('n', 'sa', require("harpoon.mark").add_file, { noremap = true, silent = true, expr = false }) + + for i = 1, terms do + vim.keymap.set('n', string.format('%s', i), function() require("harpoon.term").gotoTerminal(1) end, + { noremap = true, silent = true, expr = false }) + end + + for i = 1, quick_binds do + vim.keymap.set( + 'n', + string.format("%s", i), + function() + require("harpoon.ui").nav_file(i) + end, + { noremap = true, silent = true, expr = false } + ) + end +end + +return M diff --git a/lua/alpha/plugins.lua b/lua/alpha/plugins.lua index d0e4c7a..7d01f99 100644 --- a/lua/alpha/plugins.lua +++ b/lua/alpha/plugins.lua @@ -65,6 +65,10 @@ return require("packer").startup(function(use) "nvim-lua/plenary.nvim", "nvim-lua/popup.nvim", }, + keys = require('alpha.harpoon').keymaps, + config = function () + require('alpha.harpoon').setup() + end }) use({ -- cgit v1.2.3