axieax/urlview.nvim

github github
utility
star 52
stars
alert-circle 1
open issues
users 1
subscribers
git-branch 1
forks
CREATED

2022-01-30

UPDATED

16 days ago


πŸ”Ž urlview.nvim

UrlView is a Neovim plugin which displays links from a variety of contexts (e.g. from a buffer, file, packer.nvim and vim-plug plugin URLs), using the built-in vim.ui.select or telescope.nvim as a picker. These entries can also be selected to be brought up in your browser.

Please note that currently, this plugin only detects URLs beginning with a HTTP(s) or www prefix for buffer and file search, but there are plans to support a more general pattern, see πŸ—ΊοΈ Roadmap.

πŸ“Έ Screenshots

:UrlView or :UrlView buffer

buffer-demo

:UrlView packer or :UrlView vimplug depending on your plugin manager of choice

packer-demo

⚑ Requirements

This plugin requires Neovim 0.6+. If necessary, please check out Alternatives for other similar plugins supporting versions prior to 0.6.

πŸš€ Usage

  1. Use the command :UrlView to see all the URLs in the current buffer.
  • For your convenience, feel free to set a keybind for this using vim.api.nvim_set_keymap
  • You can also hit :UrlView <tab> to see additional contexts that you can search from
    • e.g. :UrlView packer to view links for installed packer.nvim plugins
  1. You can optionally select a link to bring it up in your browser.

πŸ“¦ Installation

Free free to install this plugin manually or with your favourite plugin manager. As an example, using packer.nvim:

use("axieax/urlview.nvim")

βš™οΈ Configuration

This plugin supports plug-n-play, meaning you can get it up and running without any additional setup.

However, you can customise the default behaviour using the setup function:

require("urlview").setup({
  -- Prompt title (`<context> <default_title>`, e.g. `Buffer Links:`)
  default_title = "Links:",
  -- Default picker to display links with
  -- Options: "native" (vim.ui.select) or "telescope"
  default_picker = "native",
  -- Set the default protocol for us to prefix URLs with if they don't start with http/https
  default_prefix = "https://",
  -- Command or method to open links with
  -- Options: "netrw", "system" (default OS browser); or "firefox", "chromium" etc.
  navigate_method = "netrw",
  -- Ensure links shown in the picker are unique (no duplicates)
  unique = true,
  -- Ensure links shown in the picker are sorted alphabetically
  sorted = true,
  -- Logs user warnings (recommended for error detection)
  debug = true,
  -- Custom search captures
  -- NOTE: captures follow Lua pattern matching (https://riptutorial.com/lua/example/20315/lua-pattern-matching)
  custom_searches = {
    -- KEY: search source name
    -- VALUE: custom search function or table (map with keys capture, format)
    jira = {
      capture = "AXIE%-%d+",
      format = "https://jira.axieax.com/browse/%s",
    },
  },
})

🎨 Pickers

βœ”οΈ Native (vim.ui.select)

You can customise the appearance of vim.ui.select with plugins such as dressing.nvim and telescope-ui-select.nvim. In the demo above, I used dressing.nvim's Telescope option, which allows me to further filter and fuzzy search through my entries.

πŸ”­ Telescope

  • Additional requirements: telescope.nvim
  • You can use Telescope as your default_picker using the require("urlview").setup function
  • Alternatively, you can specify a picker dynamically with :UrlView <ctx> picker=telescope
  • If you really want access to :Telescope urlview, then add the following line to your config:
require("telescope").load_extension("urlview")

πŸ›οΈ Alternatives

🚧 Extras

More features are continually being added to this plugin (see πŸ—ΊοΈ Roadmap). Feel free to file an issue or create a PR for any features / fixes :)