A lightweight Neovim plugin that automatically highlights URLs in your buffers. Minimal Lua port of vim-highlighturl.
- ๐ Automatic URL detection and highlighting (http, https, ftp, file, ssh, git, and more)
- โก Performance optimized with debounced updates and cached lookups
- ๐จ Customizable highlight color
- ๐ Filetype ignore list to skip specific buffer types
- ๐ Buffer-local disable/enable control
- ๐ Global toggle to quickly turn highlighting on/off
Using lazy.nvim:
{
"rubiin/highlighturl.nvim",
event = "VeryLazy",
config = true,
}Using packer.nvim:
use {
"rubiin/highlighturl.nvim",
config = function()
require("highlighturl").setup()
end
}Using vim-plug:
call plug#begin('~/.vim/plugged')
Plug 'rubiin/highlighturl.nvim'
call plug#end()
" Configure (in your vimrc/init.vim)
lua << EOF
require('highlighturl').setup()
EOFThe plugin works out of the box with sensible defaults. Call setup() only if you want to customize:
require("highlighturl").setup({
-- Filetypes to skip highlighting
ignore_filetypes = { "qf", "help", "NvimTree", "gitcommit" },
-- URL highlight color (supports hex colors)
highlight_color = "#5fd7ff",
-- Debounce delay (ms) for TextChanged events (improves performance)
debounce_ms = 100,
-- Whether to underline URLs
underline = true,
-- Suppress toggle notifications
silent = false,
})| Option | Type | Default | Description |
|---|---|---|---|
ignore_filetypes |
table |
{ "qf", "help", "NvimTree", "gitcommit" } |
List of filetypes where URL highlighting is disabled |
highlight_color |
string |
"#5fd7ff" |
Hex color for highlighted URLs |
debounce_ms |
number |
100 |
Milliseconds to wait before updating highlights after text changes |
underline |
boolean |
true |
Whether to underline URLs |
silent |
boolean |
false |
Suppress notification messages on toggle |
| Command | Scope | Description |
|---|---|---|
:URLHighlightToggle |
Global | Toggle URL highlighting on/off for all buffers |
:URLHighlightDisable |
Buffer | Disable URL highlighting for the current buffer only |
:URLHighlightEnable |
Buffer | Re-enable URL highlighting for the current buffer |
You can also control highlighting programmatically:
local highlighturl = require("highlighturl")
-- Global toggle
highlighturl.toggle()
-- Buffer-local control
highlighturl.disable_for_buffer() -- disable for current buffer
highlighturl.disable_for_buffer(bufnr) -- disable for specific buffer
highlighturl.enable_for_buffer() -- re-enable for current buffer
highlighturl.enable_for_buffer(bufnr) -- re-enable for specific buffer
-- Manual highlight refresh
highlighturl.highlight_urls()You can also set the buffer variable directly:
vim.b.highlighturl_disabled = true -- disable for current buffer
vim.b.highlighturl_disabled = false -- re-enablehttp://,https://ftp://file://ssh://git://user@host.domain:(SCP-style)
MIT