-
-
Notifications
You must be signed in to change notification settings - Fork 0
Plugin: Harpoon
The Rabbit is a basic listing that allows you to set up a workspace. You can add and remove buffers (not marks), similar to
ThePrimeagen/Harpoon.
Note
This is simply emulating functionality, and has absolutely nothing to do with Prime's plugin whatsoever.
If you want to use similar keybinds, along the lines of ui.nav_file(n)
, you can set up the following:
function rabbit_select(n)
require("rabbit").Switch("harpoon")
require("rabbit").func.select(n)
end
vim.keymap.set("n", "<C-h>", function() rabbit_select(1) end)
vim.keymap.set("n", "<C-t>", function() rabbit_select(2) end)
vim.keymap.set("n", "<C-n>", function() rabbit_select(3) end)
vim.keymap.set("n", "<C-s>", function() rabbit_select(4) end)
require("rabbit").setup({ ---@type Rabbit.Options
plugin_opts = { harpoon = { opts = { ---@type Rabbit.Plugin.Harpoon.Options
ignore_opened = false,
}}},
})
field | type | default | description |
---|---|---|---|
ignore_opened |
bool | false | If true, this will not list buffers currently open |
path_key |
str | func():str
|
nil | Scoped directory, wiki |
-- Grabbing the raw plugin instance like this is NOT recommended
local harpoon = require("rabbit").plugins.harpoon
-- This is the recommended way since it also opens the Rabbit window
-- Any variables that need to be set will be set
local harpoon = require("rabbit").Switch("harpoon")
harpoon.func.file_add(...)
harpoon.func.file_add(ln)
Adds the current (or last deleted) file at the current cursor position
Parameters
ln
: integer - Current line number (not bounded)
harpoon.func.file_del(...)
harpoon.func.file_del(ln)
Deletes the file at the current cursor position.
Also sets the deleted entry as "current file" so you can move it around.
Parameters
ln
: integer - Current line number (not bounded)
harpoon.func.group(...)
harpoon.func.group(ln)
Creates a new collection at the current cursor position. Also asks the user for the collection name.
*If you delete a collection, fear not! file_del
and file_add
manages this too.
Parameters
ln
: integer - Current line number (not bounded)
harpoon.func.group_up()
harpoon.func.group_up()
Moves to the parent collection, if applicable.
Use #harpoon.listing.paths > 0
to check if harpoon is in a collection
harpoon.func.select(...)
harpoon.func.select(ln)
Selects the current entry. It will open the collection or file.
Parameters
ln
: integer - Current line number (not bounded)
v3b
- Action keys (1-9) now work properly when selecting a collection
v3a
- A few optimizations to take advantage of new Rabbit features
- Fixed a bug where switching the
path_key
's output would break
v3
- Fixed a bug where switching the cwd would attempt to follow the path of the previous cwd and break
-
Added a
path_key
option, see wiki for details
v2
- Now supports collections, so you can make folders inside of harpoon for subprojects
v1a
-
Fixed a bug where you could duplicate entries out of bounds
I had the right code, just in the wrong spot 🤦
-
Fixed a bug where you could duplicate entries out of bounds
v1
- Initial release