For productivity addicts who enjoys coding while listening to Spotify

🎵 nvim-spotify

For productivity addicts who enjoys coding while listening to Spotify, but hates switching to the app to control the music. image

Features

  • Telescope to display the search results image
  • Pause/Resume a track
  • Skip a track
  • Add a track to the library
  • Display the name of what's being played
  • Select which device to play on
  • Search by:
    • Track (<C-T> or CR)
    • Album (<C-L>)
    • Playlist (<C-Y>)
    • Artist (<C-R>)

Requirements

Unlike other Spotify plugins, you don't need to create an app, and no server is needed on your machine. Although, you still need to authorize this plugin, so it can control your music.

A refresh token. You need to authorize the nvim-spotify app through this link and add the refresh_token that is returned to the plugin configuration.

  • Golang
  • Telescope

Installation

packer

-- Lua
use {
    'KadoBOT/nvim-spotify', 
    requires = 'nvim-telescope/telescope.nvim',
    config = function()
        local spotify = require'nvim-spotify'

        spotify.setup {
            refresh_token = "YOUR_REFRESH_TOKEN"
        }
    end,
    run = 'make'
}

Configuration

A valid refresh_token is required for this plugin to work. You can retrieve yours after authorizing the app using this link

Usage

Default keymaps:

The following keymaps are set by default when the Spotify plugin window is open:

{"n", "<Esc>"} // close the plugin window
{"n", "q"} // close the plugin window
{"n", "<C-N>"} // Select the next device in the list
{"n", "<Tab>"} // Select the next device in the list
{"n", "<S-Tab>"} // Select the previous device in the list
{"n", "<C-P>"} // Select the previous device in the list
{"n", "<C-T>"} // Search for tracks
{"n", "<C-R>"} // Search for artists
{"n", "<C-L>"} // Search for albums
{"n", "<C-Y>"} // Search for playlists
{"i", "<CR>"}  // Search for tracks
{"i", "<C-N>"} // Select the next device in the list
{"i", "<Tab>"} // Select the next device in the list
{"i", "<C-P>"} // Select the previous device in the list
{"i", "<S-Tab>"} // Select the previous device in the list
{"i", "<C-T>"} // Search for tracks
{"i", "<C-R>"} // Search for artists
{"i", "<C-L>"} // Search for albums
{"i", "<C-Y>"} // Search for playlists

Extra keymaps

You can also define the additional following keymaps

vim.api.nvim_set_keymap("n", "<leader>sn", "<Plug>(SpotifySkip)",  { silent = true }) -- Skip the current track
vim.api.nvim_set_keymap("n", "<leader>sp", "<Plug>(SpotifyPause)", , { silent = true }) -- Pause/Resume the current track
vim.api.nvim_set_keymap("n", "<leader>ss", "<Plug>(SpotifySave)",  { silent = true }) -- Add the current track to your library
vim.api.nvim_set_keymap("n", "<leader>so", ":Spotify<CR>",  { silent = true }) -- Open Spotify plugin window

Sponsoring

As you might have noticed, I'm hosting the server for handling all the requests on GCP, so you don't have to run it on your machine. While a single request is not expensive, a single user makes 5 requests every time it opens the plugin and run a search. With the increasing amount of users using this plugin, this might get more expensive. With that said, please consider sponsoring me. Thanks!

Owner
Ricardo Ambrogi
Code and pizzas.
Ricardo Ambrogi
Comments
  • Error running :Spotify

    Error running :Spotify

    Hello @KadoBOT

    Thanks for making this incredible plugin! I just installed it, authorized nvim-spotify through the link and set the refresh token but when I run :Spotify I get this error:

    Screen Shot 2021-12-25 at 11 43 43 AM

    OS:

    • MacOS Monterey
    • go version: go version go1.17.5 darwin/amd64

    Any clue why I'm getting this error please?

  • Keybindings for Pause and Next not working

    Keybindings for Pause and Next not working

    I tried using the keybindings as given in the readme,

    vim.api.nvim_set_keymap("n", "<leader>sp", "<Plug>(SpotifyPause)", , { silent = true }) -- Pause/Resume the current track
    

    (btw notice the duplicated comma which has to be removed after "SpotifyPause)")

    The keymap showed up in my which-key pop-up but did not pause the playback. My logfile did not show anything suspicious:

    $ cat /tmp/nvim-spotify-plugin.log
    Registering Plugin
    getting devices
    [[pop-os]]
    

    I looked up the definition of SpotifyPause here:

    https://github.com/KadoBOT/nvim-spotify/blob/5694a08f783b3288a4655a95fc737cc7b7c7a3c9/lua/nvim-spotify.lua#L131

    After some experimenting, the following keymap works:

    vim.api.nvim_set_keymap("n", "<leader>sp", ":call SpotifyPlayback('pause')<CR>",
                            {silent = true}) -- Pause/Resume the current track
    

    So I had to remove the <c-u> part. AFAIK I have not changed the <c-u> binding, so I'm not sure why this worked.

  • [Feature Request] Function for previous track

    [Feature Request] Function for previous track

    Pretty self-explanatory, it'd be great to have something like

    vim.api.nvim_set_keymap("n", "<leader>sb", ":call SpotifyPlayback('previous')<CR>",
                            {silent = true}) -- Play the previous track
    
  • No Playlists Appear

    No Playlists Appear

    I'm not seeing playlists when I search using C-Y from :Spotify.

    As a side note, if no playlists are found, this part of entry_fn fails:

        return function(entry)
            return {
                artist = entry[2],
                track = entry[1],
                uri = entry[3],
                display = make_display,
                ordinal = entry[1] .. entry[2],
            }
        end
    

    I modified it to

        return function(entry)
    		local artist = entry[2];
    
    		if not artist then
    			artist = 'Unknown'
    		end
    
            return {
                artist = entry[2],
                track = entry[1],
                uri = entry[3],
                display = make_display,
                ordinal = entry[1] .. artist,
            }
        end
    

    Which fixes the "attempted to concatenate nil value entry[2]" message, but the larger issues is that playlists aren't returned at all. I went through my playlists and removed one that had no title, that still hasn't fixed anything.

    My /tmp/nvim-spotify-plugin.log:

    Registering Plugin
    Configuring Plugin
    Creating Anchor
    Creating Placeholder
    cur playing
    Creating Input
    Setting Keymaps
    starting search...
    

    I have spotify-tui running and showing my playlists.

  • Fix small error in setup instructions for packer

    Fix small error in setup instructions for packer

    There's an extra comma on this line here that breaks setup and installation.

    https://github.com/KadoBOT/nvim-spotify/blob/e9464b23e48a21fc65f968d2b98155e710811fc1/README.md?plain=1#L38

    Fix: Remove the comma

    I'd love to contribute!

  • (RVV-A0006) Functions prefixed with `Get` should return a value

    (RVV-A0006) Functions prefixed with `Get` should return a value

  • (RVV-A0003) Exit inside non-main function detected

    (RVV-A0003) Exit inside non-main function detected

    Description

    Packages exposing functions that can stop program execution by exiting are hard to reuse. Program exits in functions other than main() or init() are not encouraged. Non-preferred way:

    Occurrences

    There are 11 occurrences of this issue in the repository.

    See all occurrences on DeepSource → deepsource.io/gh/KadoBOT/nvim-spotify/issue/RVV-A0003/occurrences/

  • (GSC-G303) Creating tempfile using a predictable path

    (GSC-G303) Creating tempfile using a predictable path

  • Too many open files

    Too many open files

    I usually leave nvim open when I finish work and let the computer go to sleep mode. Whenever I come back I keep getting this message dozens of times until I can use nvim again. I usually have to reopen it...

    image

  • Cannot show currently playing song in lualine

    Cannot show currently playing song in lualine

    My config is as follows:

    				local status = require("nvim-spotify").status
    				status:start()
    
    				require("lualine").setup({
    					options = {
    						theme = bubbles_theme,
    						component_separators = "|",
    						section_separators = { left = "", right = "" },
    					},
    					sections = {
    						lualine_a = {
    							{ "mode", separator = { left = "" }, right_padding = 2 },
    						},
    						lualine_b = { "filename", "branch" },
    						lualine_c = { "fileformat" },
    						lualine_x = { status.listen },
    						lualine_y = { "filetype", "progress" },
    						lualine_z = {
    							{ "location", separator = { right = "î‚´" }, left_padding = 2 },
    						},
    					},
    					inactive_sections = {
    						lualine_a = { "filename" },
    						lualine_b = {},
    						lualine_c = {},
    						lualine_x = {},
    						lualine_y = {},
    						lualine_z = { "location" },
    					},
    					tabline = {},
    					extensions = {},
    				})
    			end,
    		})
    
  • Toggling shuffle

    Toggling shuffle

    I can only shuffle the playlist if I go to spotify-tui and then toggle shuffle. I was wondering if there was a way I could do this inside neovim or if this is a feature that has not been added yet.

  • Not able to run `Spotify` or any command

    Not able to run `Spotify` or any command

    I have installed nvim-spotify as mentioned in the README.md. But somehow it throws this error. It shows the status in the lualine but is not able to control it from neovim because mapping doesn't work and commands throw errors.

    • while running Spotify image

    • while running the mapping for `(SpotifySkip) image

  • Possible idea: Preserve the current source of idea when choosing a new song

    Possible idea: Preserve the current source of idea when choosing a new song

    When selecting a new track in the :Spotify menu, preserve the current device where I am playing the music.

    Whenever I am choose a new song (listening music from my phone), the song always starts playing on the laptop, forcing the user executing :SpotifyDevices (in my case this function, along with the skip, save and so on are not working, but I will try to debug it first)

  • error from telescope when pressing ctrl-y in searchbox

    error from telescope when pressing ctrl-y in searchbox

    I wanted to search for playlists and tried with ctrl-y when the search box was open. It did change to the playlist searchbox but showed this error consistently:

    [telescope] [WARN  11:25:49] ...ck/packer/start/telescope.nvim/lua/telescope/pickers.lua:467: Finder failed with msg:  ...site/pack/packer/start/nvim-spotify/lua/nvim-spotify.lua:54: attempt to concatenate a
    nil value
    { "" }
    

    searching for playlists did not work and gave this error (I searched for a word I know I have in a playlist):

    E5108: Error executing lua ...site/pack/packer/start/nvim-spotify/lua/nvim-spotify.lua:72: attempt to concatenate field 'uri' (a nil value)
    stack traceback:
            ...site/pack/packer/start/nvim-spotify/lua/nvim-spotify.lua:72: in function 'run_replace_or_original'
            ...packer/start/telescope.nvim/lua/telescope/actions/mt.lua:30: in function 'key_func'
            ...k/packer/start/telescope.nvim/lua/telescope/mappings.lua:235: in function 'execute_keymap'
            [string ":lua"]:1: in main chunk
    
Libraries and CLIs for my personal all-in-one productivity system including components like bookmarks, notes, todos, projects, etc.

bntp.go Libraries and CLIs for my personal all-in-one productivity system including components like bookmarks, notes, todos, projects, etc. Neovim int

Sep 13, 2022
Visp is a Vi-like Spotify client for terminal users.
Visp is a Vi-like Spotify client for terminal users.

Visp Visp is an interactive console client for Spotify, written in Go. Its interface is similar to Vim, and aims to be fast, configurable, and practic

Dec 31, 2022
A spotify shell client in go.

libman Libman is an interactive spotify shell. Features Control your spotify playback. Edit playlists. Fully complies to the spotify web api terms of

Oct 16, 2022
Go package and server app for retrieving time-stamped lyrics from Spotify.

lyricsapi Go package and server app for retrieving time-stamped lyrics from Spotify. Usage Use as package go get github.com/raitonoberu/lyricsapi pack

Nov 18, 2022
Spotify clone server for golang
Spotify clone server for golang

Spotify-clone-server Written by ?? rasulov-emirlan ?? sultanaliev-s ?? Howe to use this server ?? create repository called "database" right next to th

Aug 31, 2022
Command-line tool to customize the official Spotify client. Supports Windows, MacOS and Linux.
Command-line tool to customize the official Spotify client. Supports Windows, MacOS and Linux.

Command-line tool to customize the official Spotify client. Supports Windows, MacOS and Linux. Features Change colors whole UI Inject CSS for advanced

Jan 2, 2023
Experimenting with the spotify api

experimenting with the spotify api trying to learn file structuring in Go as well as put some hours in, in the language preps for a backend service I

Dec 11, 2021
Convert your Youtube Playlists into Spotify Playlists

yt2spotify Description This is an application that allow a Spotify user to migra

Dec 28, 2021
Spotify lyrics in your terminal.

sptlrx Spotify lyrics in your terminal. Features Timesynced lyrics in your terminal. Fully compatible with spotifyd. Works well with long lines & Unic

Jan 1, 2023
Spoti2wall: Set the Spotify album cover you are currently playing as your wallpaper

?? spoti2wall Set the Spotify album cover you are currently playing as your wall

Dec 5, 2022
espnwrapper to track real time scores for your fav match... in a terminal while working.
espnwrapper to track real time scores for your fav match... in a terminal while working.

An espncricinfo wrapper written in go to track scores in real time and in the cmd/cli you can find the Command Line Interface wrapped over this wrapper.

Mar 13, 2022
Coding challenge for fullstack and backend developer candidates

todotxt Yet another a Go library for Gina Trapani's todo.txt files. ✅ Features Based on go-todotxt from Fabio Berchtold with: Go mod support Segments

Dec 10, 2022
Podbit is a replacement for newsboat's standard podboat tool for listening to podcasts.

Podbit - Podboat Improved Podbit is a replacement for newsboat's standard podboat tool for listening to podcasts. It is minimal, performant and abides

Dec 8, 2022
A utility for sending and listening for OSC messages.

A simple utility to send and listen for OSC messages. It can also be used to send MIDI messages.

Mar 5, 2022
Command-line tool for listening log file of game named as

Path of Exile Trade Notifier Command-line tool for listening log file of game named as "Path of Exile" and looking for buy message and send it to Tele

Apr 15, 2022
A memory-safe SSH server, focused on listening only on VPN networks such as Tailscale

Features Is tested to work with SCP Integrates well with systemd Quickstart Download binary for your architecture. We only support Linux. If you don't

Jun 10, 2022
Automatically exposes the remote container's listening ports back to the local machine

Auto-portforward (apf) A handy tool to automatically set up proxies that expose the remote container's listening ports back to the local machine. Just

Dec 15, 2022
Microservice framework following best cloud practices with a focus on productivity.

patron Patron is a framework for creating microservices, originally created by Sotiris Mantzaris (https://github.com/mantzas). This fork is maintained

Dec 22, 2022
A high productivity, full-stack web framework for the Go language.

Revel Framework A high productivity, full-stack web framework for the Go language. Current Version: 1.0.0 (2020-07-11) Supports go.mod package managem

Jan 7, 2023