-
Notifications
You must be signed in to change notification settings - Fork 0
Theme
Jack Huang edited this page Feb 13, 2025
·
4 revisions
A Theme is a collection of Sound. Just like how colorschemes map colors to text objects, themes map sound effects to Neovim events.
The plugin comes with three built-in themes:
-
chiptune
: Classic 8-bit game sounds (default) -
crystal
: Clear, crystalline sounds with sparkling tones -
synth
: Modern synthesizer sounds with smooth tones
When an event occurs (like saving a file or moving the cursor), the theme plays its corresponding sound effect.
See Sound for details of creating a sound.
You can also use the preset chiptune theme as a starting point.
-
First, create a table of
Sound
you like -
Then, you can either:
-
Assign it to
opts.theme
:opts = { theme = { -- your table of sounds } }
-
Or load it with
load_theme()
:---@type PlayerOne.Theme local my_theme = { -- Play a welcome jingle when Vim startup ---@type PlayerOne.Sound { event = "VimEnter", sound = { { wave_type = 1, base_freq = 523.25, env_decay = 0.15 }, { wave_type = 1, base_freq = 659.25, env_decay = 0.15 }, { wave_type = 1, base_freq = 783.99, env_decay = 0.15 }, }, callback = "append" -- Play notes sequentially }, -- Trigger a Short blip while typing { event = "TextChangedI", sound = { wave_type = 1, base_freq = 880.0, env_attack = 0.0, env_sustain = 0.001, env_decay = 0.05, }, callback = "play" -- Play immediately }, -- Play a goodbye chime when exiting Vim { event = "VimLeavePre", sound = { { wave_type = 2, base_freq = 587.33, env_decay = 0.15 }, { wave_type = 2, base_freq = 880.00, env_decay = 0.15 }, }, callback = "play_async" -- Play and wait for completion } } -- Apply the theme require("player-one").setup({ theme = my_theme }) -- Or switch themes at runtime require("player-one").load_theme(my_theme)
-