A very simple plugin that allows multiple custom vim.ui.open
handlers to
co-exist, allowing you to extend gx
while retaining the default behaviour.
demonstration.webm
- Neovim v0.10 or later (nightly currently)
{
"mrshmllow/open-handlers.nvim",
-- We modify builtin functions, so be careful lazy loading
lazy = false,
cond = vim.ui.open ~= nil,
config = function()
local oh = require("open-handlers")
oh.setup({
-- In order, each handler is tried.
-- The first handler to successfully open will be used.
handlers = {
oh.issue, -- A builtin which handles github and gitlab issues
oh.commit, -- A builtin which handles git commits
oh.native -- Default native handler. Should always be last
},
})
end,
},
Opens Github and Gitlab issues in your browser, based on current :pwd git origin.
vim.ui.open("#10")
will open issue number 10 in your browser.
Opens commits in your browser, based on current :pwd git origin.
vim.ui.open("596745da31fcefc180d2c331805f303b558e7e82")
will open commit
596745 in your browser.
vim.ui.open("596745")
will open git commit 596745 in your browser.
Equivalent to vim.ui.open
before it is overwritten.
Any custom handlers should copy vim.ui.open
’s function signature. If it
returns nil, nil
it will be ignored. See source for examples.