Skip to content

Instantly share code, notes, and snippets.

@MichaelCduBois
Last active April 2, 2024 20:22
Show Gist options
  • Save MichaelCduBois/87fd2a49b196d1bfdb9174114c7b6e0e to your computer and use it in GitHub Desktop.
Save MichaelCduBois/87fd2a49b196d1bfdb9174114c7b6e0e to your computer and use it in GitHub Desktop.
This code snippet defines a configuration file for the Harpoon project. It sets up various keymaps and files to be used in Vim, such as "ThePrimeagen/harpoon", "Harpoon2", or "Nua-lua" dependencies with lazy dependency

Neovim Harpoon Plugin Configuration

Preview:
return {
  {
    'ThePrimeagen/harpoon',
    branch = 'harpoon2',
    dependencies = {
      'nvim-lua/plenary.nvim',
    },
    lazy = false,
    config = function()
      local harpoon = require('harpoon')
      harpoon:setup({})

      -- File Operations
      vim.keymap.set('n', '<leader>hm', function() harpoon:list():append() end, { desc = 'Harpoon: Add current file' })
      vim.keymap.set('n', '<leader>ha', function() harpoon.ui:toggle_quick_menu(harpoon:list()) end, { desc = 'Harpoon: List all Harpoon files' })

      -- File Selection
      vim.keymap.set('n', '<leader>hh', function() harpoon:list():select(1) end, { desc = 'Harpoon: Select Harpoon file 1'})
      vim.keymap.set('n', '<leader>hj', function() harpoon:list():select(2) end, { desc = 'Harpoon: Select Harpoon file 2'})
      vim.keymap.set('n', '<leader>hk', function() harpoon:list():select(3) end, { desc = 'Harpoon: Select Harpoon file 3'})
      vim.keymap.set('n', '<leader>hl', function() harpoon:list():select(4) end, { desc = 'Harpoon: Select Harpoon file 4'})

      vim.keymap.set('n', '<leader>hda', function() harpoon:list():clear() end, { desc = 'Harpoon: Clear all Harpoon files' })
      vim.keymap.set('n', '<leader>hdh', function() harpoon:list():removeAt(1) end, { desc = 'Harpoon: Clear Harpoon file 1' })
      vim.keymap.set('n', '<leader>hdj', function() harpoon:list():removeAt(2) end, { desc = 'Harpoon: Clear Harpoon file 2' })
      vim.keymap.set('n', '<leader>hdk', function() harpoon:list():removeAt(3) end, { desc = 'Harpoon: Clear Harpoon file 3' })
      vim.keymap.set('n', '<leader>hdl', function() harpoon:list():removeAt(4) end, { desc = 'Harpoon: Clear Harpoon file 4' })
    end,
  },
}
Associated Context
Type Code Snippet ( .pl )
Associated Tags ThePrimeagen/harpoon Harpoon2 Nvim-lua/plenary nvim Config function Local harpoon File Operations File Selection Vim Keymap RemoveAt() Framework: Neovim Neovim plugin File management Lua scripting
💡 Smart Description This code snippet defines a configuration file for the Harpoon project. It sets up various keymaps and files to be used in Vim, such as "ThePrimeagen/harpoon", "Harpoon2", or "Nua-lua" dependencies with lazy dependency
Configure the Neovim Harpoon plugin for efficient file management and navigation.
🔎 Suggested Searches Vim harpoon file operations
Related Links https://code.visualstudio.com/docs/getstarted/keybindings
https://code.visualstudio.com/docs/editor/tasks
https://neovim.io/
https://github.com/ThePrimeagen/harpoon
Related People Michael duBois
Sensitive Information No Sensitive Information Detected
Shareable Link https://8aa4fa8a-a2a8-4c02-9a24-ba2a063e3e1a.pieces.cloud/?p=73764ea031
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment