Cmus source for unite to play & queue π΅.
You should of course have unite installed.
Use your preferred method to install the plugin(s), I recommend you to use a plugin manager.
e.g with Vim-plug using group dependencies feature.
Plug 'KabbAmine/unite-cmus' | Plug 'Shougo/unite.vim'
The plugin provides 2 sources: cmus
and cmus/album
.
Due to caching, the candidates are gathered very quickly except for the 1st time, (Depending of your music library).
π΅ π΅ π΅ π΅ π΅ π΅
:Unite cmus
Search for paths and file names.
See the gif above.
π΅ π΅ π΅ π΅ π΅ π΅
`:Unite cmus/album`
Search for paths, file names and albums.
N.B:
- This source can be slow to get candidates the 1st time.
- Due to vim's limitations, the formatting of non-ASCII characters may be strange (A PR is welcome).
π΅ π΅ π΅ π΅ π΅ π΅
action | description |
---|---|
play |
Play the selected track (Action by default) |
queue |
Add the selected track(s) to the queue playlist |
prepend2queue |
Prepend the selected track(s) to the queue playlist |
In g:unite_cmus_cache_dir
you can specify a directory where the cache files wil be stored
By default they are created in g:unite_data_directory . '/cmus/'
(Which if using unite's default configuration expends to $XDG_CACHE_HOME/unite/cmus/
).
A global and unique function is provided to get some useful informations:
cmus#get()
It contains 2 properties & 1 method:
-
cache_dir
Returns the cache directory.
-
current
Returns a dictionnary containing informations about the the current played song:
{'artist': artist, 'title': title, 'album': album}
. -
statusline_str()
Returns a nicely formatted string to use in a function for statusline:
β¬ artist - title
This is what it looks like in my config (I show/hide it with a key mapping):
You may not need it, but if you want to have a global command to control cmus from vim, add this portion of code to your vimrc
(Adapt s:cmusCmds
to your needs):
if executable('cmus')
let s:cmusCmds = {
\ '-play' : 'p',
\ '-pause' : 'u',
\ '-stop' : 's',
\ '-next' : 'n',
\ '-previous' : 'r',
\ '-repeat' : 'R',
\ '-shuffle' : 'S',
\ }
command! -nargs=? -complete=custom,CompleteCmus Cmus :call <SID>Cmus('<args>')
function! <SID>Cmus(...) abort
let l:arg = exists('a:1') && !empty(get(s:cmusCmds, a:1)) ?
\ get(s:cmusCmds, a:1) : 'u'
silent call system('cmus-remote -' . l:arg)
endfunction
function! CompleteCmus(A, L, P) abort
return join(keys(s:cmusCmds), "\n")
endfunction
endif
Then you'll have access to the command :Cmus
(Use -pause
when no argument is provided).
Thanks to Bram Moolenaar for creating the best piece of software in the world β€οΈ
Thanks to @shougo for the wonderful unite.
Thanks to you if you're using unite-cmus.
MIT