Skip to content

A very simple plugin that allows multiple custom vim.ui.open handlers to co-exist

License

Notifications You must be signed in to change notification settings

mrshmllow/open-handlers.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

open-handlers.nvim

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

Requirements

  • Neovim v0.10 or later (nightly currently)

Setup

lazy.nvim

{
  "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,
},

Usage

oh.issue

Opens Github and Gitlab issues in your browser, based on current :pwd git origin.

Example:

vim.ui.open("#10") will open issue number 10 in your browser.

oh.commit

Opens commits in your browser, based on current :pwd git origin.

Example

vim.ui.open("596745da31fcefc180d2c331805f303b558e7e82") will open commit 596745 in your browser.

vim.ui.open("596745") will open git commit 596745 in your browser.

oh.native

Equivalent to vim.ui.open before it is overwritten.

Writing custom handlers

Any custom handlers should copy vim.ui.open’s function signature. If it returns nil, nil it will be ignored. See source for examples.

About

A very simple plugin that allows multiple custom vim.ui.open handlers to co-exist

Topics

Resources

License

Stars

Watchers

Forks

Languages