All pastes #1091856 Raw Edit

Something

public text v1 · immutable
#1091856 ·published 2008-08-03 15:55 UTC
rendered paste body
" VIMPD
" MPD client for VIM
" by Skippy the Kangoo <Skippythekangoo AT yahoo DOT fr>

if exists('loaded_plugin_vimpd')
    finish
endif
let loaded_plugin_vimpd = 1

if version < 700
    echo "vimpd.vim plugin requires Vim 7 or above" finish
endif

if !has('python')
    s:ErrMsg( "Error: Required vim compiled with +python" )
    finish
endif

python << EOF

import mpdclient2, os, vim

class MPD:

    def __init__(self):
        host = "localhost"
        port = 6600
        client = mpd.MPDClient()

    def connect(self):
        client.connect()

    def disconnect(self):
        client.disconnect()

    def toggle(self):
        client.toggle()

    def next(self):
        client.next()

    def previous(self):
        client.prev()

mpdClient = MPD()

    def connectFile(self):
	try:
	    mpdClient.connect()

    def disconnectFile(self):
	try:
	    mpdClient.disconnect()

    def toggleFile(self):
	try:
	    mpdClient.toggle()
EOF

fun! MpdConnect()
    python connectFile()
endfun

fun! MpdDisconnect()
    python disconnectFile()
endfun

fun! MpdToggle()
    python toggleFile()
endfun