#compdef ly-fu
#
# ZSH completion for ly-fu. Install to a $fpath directory. Consult the
# perl distribution of the App::MusicTools module for the related CLI
# program. This completion is from the zsh-compdef/ subdirectory of that
# perl distribution.

local ret=1

# Extracted from share/lilypond/2.14.2/scm/midi.scm, excepting drums and
# some other wacky instruments. Create lyinstruments elsewhere (e.g. in
# ~/.zshrc) to customize the list.
if [[ ${#lyinstruments} -eq 0 ]]; then
  lyinstruments=(
    accordion
    "acoustic bass"
    "acoustic grand"
    "acoustic guitar (nylon)"
    "acoustic guitar (steel)"
    agogo
    "alto sax"
    bagpipe
    banjo
    "baritone sax"
    bassoon
    "blown bottle"
    "brass section"
    "bright acoustic"
    celesta
    cello
    "choir aahs"
    "church organ"
    clarinet
    clav
    concertina
    contrabass
    "distorted guitar"
    "drawbar organ"
    dulcimer
    "electric bass (finger)"
    "electric bass (pick)"
    "electric grand"
    "electric guitar (clean)"
    "electric guitar (jazz)"
    "electric guitar (muted)"
    "electric piano 1"
    "electric piano 2"
    "english horn"
    fiddle
    flute
    "french horn"
    "fretless bass"
    "fx 1 (rain)"
    "fx 2 (soundtrack)"
    "fx 3 (crystal)"
    "fx 4 (atmosphere)"
    "fx 5 (brightness)"
    "fx 6 (goblins)"
    "fx 7 (echoes)"
    "fx 8 (sci-fi)"
    glockenspiel
    "guitar harmonics"
    harmonica
    harpsichord
    honky-tonk
    kalimba
    koto
    "lead 1 (square)"
    "lead 2 (sawtooth)"
    "lead 3 (calliope)"
    "lead 4 (chiff)"
    "lead 5 (charang)"
    "lead 6 (voice)"
    "lead 7 (fifths)"
    "lead 8 (bass+lead)"
    marimba
    "melodic tom"
    "music box"
    "muted trumpet"
    oboe
    ocarina
    "orchestra hit"
    "orchestral harp"
    "overdriven guitar"
    "pad 1 (new age)"
    "pad 2 (warm)"
    "pad 3 (polysynth)"
    "pad 4 (choir)"
    "pad 5 (bowed)"
    "pad 6 (metallic)"
    "pad 7 (halo)"
    "pad 8 (sweep)"
    "pan flute"
    "percussive organ"
    piccolo
    "pizzicato strings"
    recorder
    "reed organ"
    "rock organ"
    shakuhachi
    shamisen
    shanai
    sitar
    "slap bass 1"
    "slap bass 2"
    "soprano sax"
    "steel drums"
    "string ensemble 1"
    "string ensemble 2"
    "synth bass 1"
    "synth bass 2"
    "synth voice"
    "synthbrass 1"
    "synthbrass 2"
    "synthstrings 1"
    "synthstrings 2"
    "taiko drum"
    "tenor sax"
    timpani
    "tinkle bell"
    "tremolo strings"
    trombone
    trumpet
    tuba
    "tubular bells"
    vibraphone
    viola
    violin
    whistle
    woodblock
    xylophone
  )
fi

# Just the command line options; probably can't complete music
_arguments \
  '(--relative)--absolute[absolute mode]' \
  '--articulate[include articulation]' \
  '--events[emit lilypond event data]' \
  '(- *)--help[display help]' \
  '--instrument=[instrument]:instrument:_values "instruments" $lyinstruments' \
  '--language=[lilypond language]:language:(nederlands catalan deutsch english espanol italiano norsk portugues suomi svenska vlaams)' \
  '--layout[save layout]' \
  '--open[display layout]' \
  '--partial=[leading expression]:expression' \
  '(--absolute)--relative=[starting note]:note:' \
  '--repeats=[number of repeats]:count:' \
  {-R,--rhythmic-staff}'[music with RhythmicStaff]' \
  '--show-code[emit lilypond to stdout and quit]' \
  '--silent[skip MIDI playback]' \
  '--sleep=[sleep kluge]:seconds:' \
  '--tempo=[tempo]:tempo:' \
  '--verbose[be verbose]' && ret=0

return $ret
