Play YouTube audio directly from Neovim using mpv + yt-dlp. No browser, no Node.js β just pure Lua talking to mpv over a local IPC socket.
mpv and yt-dlp.:YT player) animated player layout featuring a custom bounding-box grid, bouncy audio visualizer, interactive progress slidebar, and built-in queue alignment.s. Manage and play them entirely within the split-pane manager (:YT playlists).dd to remove tracks or J/K to reorder them (:YT queue_edit).:YT queue_playlist).lualine| Dependency | Install |
|---|---|
| Neovim 0.9+ | β |
| mpv | sudo apt install mpv or brew install mpv |
| yt-dlp | pip install yt-dlp or binary release |
{
"sanjay-np/nvim-yt-player",
config = function()
require("yt-player").setup()
end,
}
use {
"sanjay-np/nvim-yt-player",
config = function()
require("yt-player").setup()
end,
}
:YT play https://www.youtube.com/watch?v=dQw4w9WgXcQ
Or search directly from Neovim (opens in a custom interactive floating window!):
:YT search lofi hip hop
In the interactive search window:
<CR> (Enter): Play result (replaces current track)<C-a> (Ctrl+A) or a / A (in Normal mode): Append result to the queues (in Normal mode): Save track to a Local PlaylistAll functionality is grouped under a single :YT command with auto-completion (press Tab!).
| Command | Description |
|---|---|
:YT play [url] |
Play URL / search, or resume |
:YT search [query] |
π Search YouTube and pick a result |
:YT queue <url> |
Append a single URL to the playlist |
:YT queue_playlist <url> |
Fetch and append an entire playlist |
:YT queue_edit |
Open interactive queue editor |
:YT pause |
Pause |
:YT toggle |
Toggle play/pause |
:YT stop |
Stop playback |
:YT next / :YT prev |
Next / previous track |
:YT seek <sec> |
Seek to absolute position |
:YT seek_rel <Β±sec> |
Seek relative |
:YT volume <0-100> |
Set volume |
:YT vol_up / :YT vol_down |
Volume Β±5 |
:YT mute |
Toggle mute |
:YT speed <rate> |
Set speed (0.25β3.0) |
:YT speed_up / :YT speed_down |
Speed Β±0.25 |
:YT shuffle / :YT repeat_toggle |
Shuffle / repeat |
:YT player |
Toggle the player side-panel |
:YT info |
Toggle the floating player window |
:YT history |
Browse play history |
:YT history_clear |
Clear play history |
:YT playlists |
Manage and play local custom playlists |
:YT radio |
Toggle radio/autoplay mode |
:YT player (side-panel) and :YT info (floating window) share the same controls:
| Key | Action |
|---|---|
p / s / t |
Play / Pause / Toggle |
n / b |
Next / Previous |
m |
Mute |
> / < |
Speed Β±0.25 |
+ / - |
Volume Β±5 |
l / h |
Seek Β±5s |
L / H |
Seek Β±30s |
r |
Toggle Radio mode |
q / <Esc> |
Close |
All options with defaults:
require("yt-player").setup({
statusline = {
enabled = true,
format = "{icon} {title} - {artist} [{position}/{duration}]",
icon_playing = "βΆ",
icon_paused = "βΈ",
truncate_title = 30,
progress_width = 10,
},
-- Search settings
search = {
limit = 10, -- number of results to fetch
},
notifications = {
enabled = true,
notify_on_track_change = true,
},
player = {
queue_display_limit = 5, -- Number of upcoming tracks to show in the `:YT player` side-panel
},
keymaps = {
enabled = false,
prefix = "<leader>y",
play = "p",
pause = "s",
toggle = "t",
next = "n",
prev = "b",
mute = "m",
volume_up = "+",
volume_down = "-",
seek_forward = "f",
seek_backward = "r",
speed_up = ">",
speed_down = "<",
info = "i",
},
sponsorblock = false, -- Set to true to automatically skip embedded sponsor segments
})
{icon} {title} {artist} {album} {position} {duration} {volume} {progress} {speed}
Example output: βΆ Song Name ββββββββββ [2:30/5:00] 1.5x
require("lualine").setup({
sections = {
lualine_x = { "yt-player" }
}
})
Neovim (Lua) ββ IPC pipe ββ mpv βββ yt-dlp βββ YouTube
The plugin spawns a headless mpv --no-video process and communicates through a UNIX domain socket using mpv's JSON IPC protocol. yt-dlp is used by mpv internally to resolve YouTube URLs into streamable media.
mpv --no-video <youtube-url> directly to verify mpv + yt-dlp workyt-dlp -U to updatepkill -f "mpv.*yt-player" or restart Neovimyt-dlp can access YouTube (check for API rate limits or geo-blocking)mpv was compiled with lua support (most distributions include it)Q: How do I play audio only (no video)?
A: The plugin automatically runs mpv --no-video by default. Video is disabled to save resources.
Q: Can I use this with YouTube Music? A: Yes! Any YouTube URL works. For music videos, you'll get the audio track with album art in the player window.
Q: Does this work with playlists?
A: Yes. Use :YT queue_playlist <playlist-url> to load an entire playlist, or :YT queue <url> for individual tracks.
Q: How does the radio mode work?
A: When enabled (press r in player window or :YT radio), the plugin will automatically queue and play related videos when the queue endsβcreating an endless listening experience.
Q: Can I use keyboard shortcuts globally? A: Yes! Enable global keymaps in config:
keymaps = {
enabled = true,
prefix = "<leader>y",
-- ... other mappings
}
| Category | Key | Action |
|---|---|---|
| Playback | p |
Play |
s |
Pause | |
t |
Toggle play/pause | |
| Navigation | n |
Next track |
b |
Previous track | |
l / h |
Seek Β±5s | |
L / H |
Seek Β±30s | |
| Volume | m |
Mute toggle |
+ / - |
Volume Β±5 | |
| Speed | > |
Speed up |
< |
Speed down | |
| Mode | r |
Toggle radio mode |
| Exit | q / Esc |
Close player |
MIT