feat: harpoon2 -> harpoon

This commit is contained in:
mpaulson 2023-11-30 14:03:51 -07:00
parent fc35ba1831
commit ac9cbed9ed
12 changed files with 61 additions and 45 deletions

View File

@ -11,18 +11,12 @@
-- image provided by **Bob Rust** -- image provided by **Bob Rust**
## ⇁ TOC ## ⇁ TOC
* [Note to legacy Harpoon 1 users](#-Note-to-legacy-Harpoon-1-users)
* [The Problems](#-The-Problems) * [The Problems](#-The-Problems)
* [The Solutions](#-The-Solutions) * [The Solutions](#-The-Solutions)
* [Installation](#-Installation) * [Installation](#-Installation)
* [Getting Started](#-Getting-Started) * [Getting Started](#-Getting-Started)
* [Social](#-Social) * [Social](#-Social)
* [Note to legacy Harpoon 1 users](#-Note-to-legacy-Harpoon-1-users)
## ⇁ Note to legacy Harpoon 1 users
Original Harpoon will remain in a frozen state and i will merge PRs in with _no
code review_ for those that wish to remain on that. Harpoon 2 is significantly
better and allows for MUCH greater control. Please migrate to that (will
become `master` within the next few months).
## ⇁ The Problems ## ⇁ The Problems
1. You're working on a codebase. medium, large, tiny, whatever. You find 1. You're working on a codebase. medium, large, tiny, whatever. You find
@ -37,17 +31,39 @@ to go to the files you want.
1. Unlimited terminals and navigation. 1. Unlimited terminals and navigation.
## ⇁ Installation ## ⇁ Installation
* neovim 0.5.0+ required * neovim 0.8.0+ required
* install using your favorite plugin manager (`vim-plug` in this example) * install using your favorite plugin manager (i am using `packer` in this case)
```vim ```lua
Plug 'nvim-lua/plenary.nvim' " don't forget to add this one if you don't have it yet! use "nvim-lua/plenary.nvim" -- don't forget to add this one if you don't have it yet!
Plug 'ThePrimeagen/harpoon' use {
"ThePrimeagen/harpoon",
branch = "0.1.x",
requires = { {"nvim-lua/plenary.nvim"} }
}
``` ```
## ⇁ Getting Started ## ⇁ Getting Started
### Quick Note
You will want to add your style of remaps and such to your neovim dotfiles with
the shortcuts you like. My shortcuts are for me. Me alone. Which also means
they are designed with dvorak in mind (My layout btw, I use dvorak btw).
```lua
local harpoon = require("harpoon")
harpoon.ui:toggle_quick_menu(harpoon:list())
```
## ⇁ Social ## ⇁ Social
For questions about Harpoon, there's a #harpoon channel on [the Primagen's Discord](https://discord.gg/theprimeagen) server. For questions about Harpoon, there's a #harpoon channel on [the Primeagen's Discord](https://discord.gg/theprimeagen) server.
* [Discord](https://discord.gg/theprimeagen) * [Discord](https://discord.gg/theprimeagen)
* [Twitch](https://www.twitch.tv/theprimeagen) * [Twitch](https://www.twitch.tv/theprimeagen)
* [Twitter](https://twitter.com/ThePrimeagen) * [Twitter](https://twitter.com/ThePrimeagen)
## ⇁ Note to legacy Harpoon 1 users
Original Harpoon will remain in a frozen state and i will merge PRs in with _no
code review_ for those that wish to remain on that. Harpoon 2 is significantly
better and allows for MUCH greater control. Please migrate to that (will
become `master` within the next few months).

View File

@ -1,4 +1,4 @@
local utils = require("harpoon2.utils") local utils = require("harpoon.utils")
local M = {} local M = {}
local HARPOON_MENU = "__harpoon-menu__" local HARPOON_MENU = "__harpoon-menu__"
@ -47,27 +47,27 @@ function M.setup_autocmds_and_keymaps(bufnr)
bufnr, bufnr,
"n", "n",
"q", "q",
"<Cmd>lua require('harpoon2').ui:toggle_quick_menu()<CR>", "<Cmd>lua require('harpoon').ui:toggle_quick_menu()<CR>",
{ silent = true } { silent = true }
) )
vim.api.nvim_buf_set_keymap( vim.api.nvim_buf_set_keymap(
bufnr, bufnr,
"n", "n",
"<ESC>", "<ESC>",
"<Cmd>lua require('harpoon2').ui:toggle_quick_menu()<CR>", "<Cmd>lua require('harpoon').ui:toggle_quick_menu()<CR>",
{ silent = true } { silent = true }
) )
vim.api.nvim_buf_set_keymap( vim.api.nvim_buf_set_keymap(
bufnr, bufnr,
"n", "n",
"<CR>", "<CR>",
"<Cmd>lua require('harpoon2').ui:select_menu_item()<CR>", "<Cmd>lua require('harpoon').ui:select_menu_item()<CR>",
{} {}
) )
-- TODO: Update these to use the new autocmd api -- TODO: Update these to use the new autocmd api
vim.cmd( vim.cmd(
string.format( string.format(
"autocmd BufWriteCmd <buffer=%s> lua require('harpoon2').ui:save()", "autocmd BufWriteCmd <buffer=%s> lua require('harpoon').ui:save()",
bufnr bufnr
) )
) )
@ -77,7 +77,7 @@ function M.setup_autocmds_and_keymaps(bufnr)
if global_config.save_on_change then if global_config.save_on_change then
vim.cmd( vim.cmd(
string.format( string.format(
"autocmd TextChanged,TextChangedI <buffer=%s> lua require('harpoon2').ui:save()", "autocmd TextChanged,TextChangedI <buffer=%s> lua require('harpoon').ui:save()",
bufnr bufnr
) )
) )
@ -90,7 +90,7 @@ function M.setup_autocmds_and_keymaps(bufnr)
) )
) )
vim.cmd( vim.cmd(
"autocmd BufLeave <buffer> ++nested ++once silent lua require('harpoon2').ui:toggle_quick_menu()" "autocmd BufLeave <buffer> ++nested ++once silent lua require('harpoon').ui:toggle_quick_menu()"
) )
end end

View File

@ -1,7 +1,7 @@
local Path = require("plenary.path") local Path = require("plenary.path")
local data_path = vim.fn.stdpath("data") local data_path = vim.fn.stdpath("data")
local full_data_path = string.format("%s/harpoon2.json", data_path) local full_data_path = string.format("%s/harpoon.json", data_path)
---@param data any ---@param data any
local function write_data(data) local function write_data(data)

View File

@ -1,8 +1,8 @@
local Ui = require("harpoon2.ui") local Ui = require("harpoon.ui")
local Data = require("harpoon2.data") local Data = require("harpoon.data")
local Config = require("harpoon2.config") local Config = require("harpoon.config")
local List = require("harpoon2.list") local List = require("harpoon.list")
local Listeners = require("harpoon2.listeners") local Listeners = require("harpoon.listeners")
-- setup -- setup
-- read from a config file -- read from a config file
@ -141,7 +141,7 @@ function Harpoon:dump()
end end
function Harpoon:__debug_reset() function Harpoon:__debug_reset()
require("plenary.reload").reload_module("harpoon2") require("plenary.reload").reload_module("harpoon")
end end
return Harpoon:new() return Harpoon:new()

View File

@ -1,5 +1,5 @@
local Listeners = require("harpoon2.listeners") local Listeners = require("harpoon.listeners")
local Buffer = require("harpoon2.buffer") local Buffer = require("harpoon.buffer")
local function index_of(items, element, config) local function index_of(items, element, config)
local equals = config and config.equals local equals = config and config.equals

View File

@ -1,3 +1,3 @@
local harpoon = require("harpoon2") local harpoon = require("harpoon")
harpoon.ui:toggle_quick_menu(harpoon:list()) harpoon.ui:toggle_quick_menu(harpoon:list())

View File

@ -1,4 +1,4 @@
local Config = require("harpoon2.config") local Config = require("harpoon.config")
local eq = assert.are.same local eq = assert.are.same
describe("config", function() describe("config", function()

View File

@ -1,5 +1,5 @@
local utils = require("harpoon2.test.utils") local utils = require("harpoon.test.utils")
local harpoon = require("harpoon2") local harpoon = require("harpoon")
local eq = assert.are.same local eq = assert.are.same
@ -8,7 +8,7 @@ local be = utils.before_each(os.tmpname())
describe("harpoon", function() describe("harpoon", function()
before_each(function() before_each(function()
be() be()
harpoon = require("harpoon2") harpoon = require("harpoon")
end) end)
it("when we change buffers we update the row and column", function() it("when we change buffers we update the row and column", function()

View File

@ -1,5 +1,5 @@
local List = require("harpoon2.list") local List = require("harpoon.list")
local Config = require("harpoon2.config") local Config = require("harpoon.config")
local eq = assert.are.same local eq = assert.are.same
describe("list", function() describe("list", function()

View File

@ -1,6 +1,6 @@
local utils = require("harpoon2.test.utils") local utils = require("harpoon.test.utils")
local Buffer = require("harpoon2.buffer") local Buffer = require("harpoon.buffer")
local harpoon = require("harpoon2") local harpoon = require("harpoon")
local eq = assert.are.same local eq = assert.are.same
local be = utils.before_each(os.tmpname()) local be = utils.before_each(os.tmpname())
@ -8,7 +8,7 @@ local be = utils.before_each(os.tmpname())
describe("harpoon", function() describe("harpoon", function()
before_each(function() before_each(function()
be() be()
harpoon = require("harpoon2") harpoon = require("harpoon")
end) end)
it("open the ui without any items in the list", function() it("open the ui without any items in the list", function()

View File

@ -1,4 +1,4 @@
local Data = require("harpoon2.data") local Data = require("harpoon.data")
local M = {} local M = {}
@ -10,10 +10,10 @@ function M.before_each(name)
Data.set_data_path(name) Data.set_data_path(name)
Data.__dangerously_clear_data() Data.__dangerously_clear_data()
require("plenary.reload").reload_module("harpoon2") require("plenary.reload").reload_module("harpoon")
Data = require("harpoon2.data") Data = require("harpoon.data")
Data.set_data_path(name) Data.set_data_path(name)
local harpoon = require("harpoon2") local harpoon = require("harpoon")
M.clean_files() M.clean_files()

View File

@ -1,5 +1,5 @@
local popup = require("plenary").popup local popup = require("plenary").popup
local Buffer = require("harpoon2.buffer") local Buffer = require("harpoon.buffer")
local DEFAULT_WINDOW_WIDTH = 69 -- nice local DEFAULT_WINDOW_WIDTH = 69 -- nice
---@class HarpoonUI ---@class HarpoonUI