1
0
mirror of https://github.com/tiyn/dotfiles.git synced 2026-03-17 22:24:46 +01:00
Files
dotfiles/.config/nvim/after/ftplugin/lilypond.lua
2026-03-14 09:22:36 +01:00

58 lines
1.1 KiB
Lua

local wk = require("which-key")
local fluidsynth_job = nil
-- setup interactive midi player
wk.add({
{ mode = "n", "<leader>p", desc = "Lilypond: output" },
{
mode = "n",
"<leader>pm",
function()
local midi = vim.fn.expand("%:r") .. ".midi"
if fluidsynth_job then
vim.fn.jobstop(fluidsynth_job)
fluidsynth_job = nil
print("fluidsynth stopped")
return
end
fluidsynth_job = vim.fn.jobstart({ "fluidsynth", "-i", midi })
print("fluidsynth playing (Ctrl-C to stop)")
end,
desc = "Lilypond: output MIDI",
buffer = true,
},
{
mode = "n",
"<leader>pp",
"<cmd>Viewer<CR>",
desc = "Lilypond: open PDF",
buffer = true,
},
{
mode = "n",
"<C-c>",
function()
if fluidsynth_job then
vim.fn.jobstop(fluidsynth_job)
fluidsynth_job = nil
print("fluidsynth stopped")
else
vim.cmd("normal! <C-c>")
end
end,
desc = "Stop MIDI playback",
buffer = true,
},
})
-- autostart
if vim.b.first_start_lilypond then
return
end
vim.b.first_start_lilypond = true
vim.cmd.Viewer()