diff --git a/README.md b/README.md index 167fe1b..60c01f1 100644 --- a/README.md +++ b/README.md @@ -203,6 +203,17 @@ This can help debug issues on other's computer. To get your debug log please do 1. execute vim command `:lua require("harpoon").logger:show()` and copy the buffer 1. paste the buffer as part of the bug creation +## Extends +THIS PART OF THE DOCS NEEDS FILLING OUT + +```lua +local harpoon = require("harpoon"); +local extensions = require("harpoon.extensions"); + +harpoon:setup() +harpoon:extend(extensions.builtins.command_on_nav("foo bar")); +``` + ## ⇁ Contribution This project is officially open source, not just public source. If you wish to contribute start with an issue and I am totally willing for PRs, but I will be diff --git a/lua/harpoon/config.lua b/lua/harpoon/config.lua index b6b61cf..df86d4d 100644 --- a/lua/harpoon/config.lua +++ b/lua/harpoon/config.lua @@ -1,3 +1,4 @@ +local Extensions = require("harpoon.extensions") local Logger = require("harpoon.logger") local Path = require("plenary.path") local function normalize_path(buf_name, root) @@ -129,6 +130,10 @@ function M.get_default_config() list_item.context.col or 0, }) end + + Extensions.extensions:emit(Extensions.event_names.NAVIGATE, { + buffer = bufnr, + }) end, ---@param list_item_a HarpoonListItem diff --git a/lua/harpoon/extensions.lua b/lua/harpoon/extensions/init.lua similarity index 79% rename from lua/harpoon/extensions.lua rename to lua/harpoon/extensions/init.lua index c5f0f49..79ebd5d 100644 --- a/lua/harpoon/extensions.lua +++ b/lua/harpoon/extensions/init.lua @@ -12,6 +12,7 @@ local HarpoonExtensions = {} ---@field UI_CREATE? fun(...): nil ---@field SETUP_CALLED? fun(...): nil ---@field LIST_CREATED? fun(...): nil +---@field NAVIGATE? fun(...): nil HarpoonExtensions.__index = HarpoonExtensions @@ -40,8 +41,21 @@ function HarpoonExtensions:emit(type, ...) end end +local extensions = HarpoonExtensions:new() +local Builtins = { +}; + +function Builtins.command_on_nav(cmd) + return { + NAVIGATE = function() + vim.cmd(cmd) + end, + } +end + return { - extensions = HarpoonExtensions:new(), + builtins = Builtins, + extensions = extensions, event_names = { ADD = "ADD", SELECT = "SELECT", @@ -50,5 +64,6 @@ return { UI_CREATE = "UI_CREATE", SETUP_CALLED = "SETUP_CALLED", LIST_CREATED = "LIST_CREATED", + NAVIGATE = "NAVIGATE", }, }