Skip to content

Open the current word with custom openers, GitHub shorthands for example.

License

Notifications You must be signed in to change notification settings

ofirgall/open.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

open.nvim

Open the current word (or other text) with custom openers, extensible.

E.g: Open GitHub shorthand "ofirgall/open.nvim" at your default browser.

Installation

use { 'ofirgall/open.nvim', requires = 'nvim-lua/plenary.nvim' }

You can install vim.ui.select wrapper to change the ui for selecting multiple results:

Troubleshoot

Usage

-- Leave empty for default values
require('open').setup {
}

require('open').setup {
    config = {
        -- Override system opener, the defaults should work out of the box
        system_open = {
            cmd = "",
            args = {},
        },
        -- Options to pass to plenary.curl
        curl_opts = {
            -- compressed = false -- Uncomment this line to disable curl compression
        },
    },
    -- List of disabled openers, 'github' for example see `:help open.default_openers`
    disabled_openers = {
    },
    -- fallback function if no opener succeeds
    fallback = function(text)
        system_open.open(text)
    end,
    -- Override `config` per opener
    openers_config = {
        -- Override `jira` browser for example
        ['jira'] = {
            system_open = {
                cmd = 'chromium-browser',
            },
        },
    },
}

By default, no keymaps are set, you have to set your own keymap:

vim.keymap.set('n', 'gx', require('open').open_cword)

Register a custom opener

Please share awesome custom openers with PR.

require('open').register_opener({
    name = 'Example Opener',
    open_fn = function(text)
        return { 'www.example.org' }
    end
})

List of Custom Openers

Feel free to add your opener to the list.

Credits

About

Open the current word with custom openers, GitHub shorthands for example.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published