Make sound response when event happen.
Tested Vim versions:
- Vim
9.0.1062
- NVIM
v0.8.2
-
Player
Abstract the underlying way Vim plays sound, try to make it portable.
Current supported backends:
-
Events
Define when to play a sound.
Can target Vim's built-in autocommands (autocommand-events).
Also provide some autoload functions (only loaded when they were really called) to handle special use cases:
ale#all-fixed
: after fix all ale lint issues in current buffer.
-
Sounds
Define available sounds.
A sound should have an
id
, apath
to real audio file or system event name (e.g.,event:x11-bell
).
In legacy Vim syntax:
let g:noise_player = 'pulseaudio'
let g:noise_sounds = [
\ #{name: 'x11 bell', id: 'x11-bell', path: 'event:x11-bell'},
\ #{name: 'Power Up', id: 'kunio-powerup', path: '/mnt/c/SE/kunio_mg2_powerup-3.wav'},
\ #{ id: 'ikaruga', path: '/mnt/c/SE/斑鳩_energy_max.aiff'},
\ ]
let g:noise_events = [
\ #{name: 'Inserted', autocmd: 'InsertLeave *', sound_id: 'x11-bell'},
\ #{name: 'SearchWrapped' autocmd: 'SearchWrapped', sound_id: 'ikaruga'},
\ #{name: 'Search wrapped' autocmd: 'User AnzuWrap', sound_id: 'ikaruga'},
\ #{name: 'ale Cleared', autoload: 'ale#all-fixed', sound_id: 'kunio-powerup'},
\ ]
let g:noise_throttle_timeout = 140 " default is 200
let g:noise_player_args = ['--latency-msec=200']
-
noise#Play({id}[, event_id])
Examples:
call noise#Play('some-id')
(some-id
must be a key ing:noise_sounds
dictionary)call noise#Play('file:/mnt/c/SE/foo.mp3')
call noise#Play('event:x11-bell')
- Currently, doesn't support dynamically reload settings, you have to restart Vim to take effect of changed settings.
Run the test script, will clone vim-themis and execute it.
./test/run.sh