Home

Awesome

Neovim Apple Music Plugin

This Neovim plugin allows you to control Apple Music directly from within Neovim using Lua and Telescope. You can play tracks, playlists, and albums, and control playback without leaving your favorite text editor.

Demo of Selecting Album via Telescope

Note: Temporary Playlists

In order to play albums, I am using a workaround described in the acknowledgements where I create temporary playlists from the songs contained in an album. This means every time you play an album it will add a playlist to your library. That is why a function exists to cleanup these temporary playlists:

require("apple-music").cleanup_all()

Features

Installation

Using lazy.nvim

Here is how I have this plugin setup, minus the dev stuff.

{
    'p5quared/apple-music.nvim',
    dependencies = { 'nvim-telescope/telescope.nvim' },
    config = true,
    keys = {
        { "<leader>amp", function() require("apple-music").toggle_play() end,               desc = "Toggle [P]layback" },
        { "<leader>ams", function() require("apple-music").toggle_shuffle() end,            desc = "Toggle [S]huffle" },
        { "<leader>fp",  function() require("apple-music").select_playlist_telescope() end, desc = "[F]ind [P]laylists" },
        { "<leader>fa",  function() require("apple-music").select_album_telescope() end,    desc = "[F]ind [A]lbum" },
        { "<leader>fs",  function() require("apple-music").select_track_telescope() end,    desc = "[F]ind [S]ong" },
        { "<leader>amx", function() require("apple-music").cleanup_all() end,               desc = "Cleanup Temp Playlists" },
    },
}

I think this is a good overview of the main functionality as well. Toggling playback is arguably just as easy to do with general keyboard shortcuts (nowadays you often have media keys). I think the ability to browse and play via telescope is the the most useful feature of this plugin.

Note that you have to manually cleanup the temporary playlists created by this plugin. In the future I may try to come up with an autocmd solution.

Configuration

You can customize the plugin by passing options to the setup function:

require('apple-music').setup({
  temp_playlist_name = "nvim_apple_music_temp"  -- Custom temporary playlist name
})

Usage

Commands

See doc/apple-music.txt for an overview of commands.

Example

To play a specific track, you can use the following command in Neovim:

:lua require('apple-music').play_track("Bohemian Rhapsody")

To open the Telescope picker and select a playlist to play:

:lua require('apple-music').select_playlist_telescope()

License

This plugin is released under the MIT License. See LICENSE for more information.

Contributions

Contributions are welcome! Please feel free to open issues or submit pull requests on GitHub. Before opening pull requests, please run stylua locally.

Acknowledgements