4. Tips and tricks - martineausimon/nvim-lilypond-suite GitHub Wiki
Add this lines to your preamble to avoid the padding on the left side and keep the score justified :
\def\preLilyPondExample{\hspace*{-3mm}}
\newcommand{\betweenLilyPondSystem}[1]{\linebreak\hspace*{-3mm}}Adjust space between systems using this line (in \renewcommand or \newcommand) :
{\betweenLilyPondSystem}[1]{\vspace{5mm}\linebreak\hspace*{-3mm}}Use nvim-overseer to run a continuous compilation pipeline every time you save an .ly file. The work-flow goes like this:
Define a template for overseer somewhere in your configuration, e.g. in your ftplugin/lilypond.lua :
local overseer = require('overseer')
overseer.register_template({
name = "lilypond",
builder = function(params)
--Use nvls options defined in require('nvls').setup() :
local file = require('nvls.config').fileInfos()
local opts = require('nvls').get_nvls_options().lilypond.options
local cmd = {
"lilypond",
"-f", opts.output,
}
local backend = opts.backend or nil
if backend then
table.insert(cmd, "-dbackend=" .. backend)
end
local include_dir = opts.include_dir or nil
if type(include_dir) == "table" then
for _, dir in ipairs(include_dir) do
table.insert(cmd, "-I")
table.insert(cmd, vim.fn.expand(dir))
end
elseif include_dir ~= nil and include_dir ~= "" then
table.insert(cmd, "-I")
table.insert(cmd, vim.fn.expand(include_dir))
end
table.insert(cmd, file.main)
return {
cmd = cmd,
name = "lilypond",
cwd = file.folder,
components = {
"default",
{
"on_output_parse", parser = {
diagnostics = {
{
"extract",
"^([^%s].+):(%d+):(%d+): (.+)$",
"filename",
"lnum",
"col",
"text"
},
}
}
},
{
"on_result_diagnostics",
remove_on_restart = true,
},
{
"on_result_diagnostics_quickfix",
open = true
},
{
"on_complete_dispose",
timeout = 600
},
},
metadata = {},
}
end,
desc = "Compile Lilypond file",
tags = { overseer.TAG.BUILD },
priority = 50,
condition = {
filetype = { "lilypond" },
},
})After opening a lilypond file, run :OverseerRun and select the job from the list. After this, run :OverseerQuickaction watch and hit enter to select current working directory.
This will start a background job where overseer compiles to pdf every time you save. If you combine this with an autosave-plugin and a pdf viewer that automatically updates, you will get live, immediate feedback on your scores.
Add this lines in your init.lua :
function floatingQF()
local qflist = vim.fn.getqflist()
for _, win in ipairs(vim.api.nvim_list_wins()) do
local buf = vim.api.nvim_win_get_buf(win)
if vim.api.nvim_buf_get_option(buf, 'buftype') == 'quickfix' then
vim.api.nvim_win_close(win, true)
break
end
end
if #qflist == 0 then return end
local width = math.floor(vim.api.nvim_win_get_width(0) * 0.90)
local win_height = vim.api.nvim_win_get_height(0)
local height = math.min(#qflist, win_height - 10)
local row = win_height - height - 3
local col = math.floor((vim.api.nvim_win_get_width(0) - width) / 2)
local buf = vim.api.nvim_create_buf(false, true)
vim.fn.setbufvar(buf, "&buftype", "quickfix")
vim.cmd('set nowrap')
local win = vim.api.nvim_open_win(buf, true, {
relative = 'editor',
width = width,
height = height,
row = row,
col = col,
style = 'minimal',
border = 'single'
})
vim.api.nvim_win_set_option(win, 'wrap', false)
vim.cmd('copen')
vim.api.nvim_buf_set_keymap(buf, 'n', 'q', ':q<CR>',
{ nowait = true, noremap = true, silent = true })
end
vim.api.nvim_create_autocmd('QuickFixCmdPost', {
callback = function()
-- Uncomment this 2 lines to stay in current buffer insted of moving to qf
-- local prev_win = vim.api.nvim_get_current_win()
floatingQF()
-- vim.api.nvim_set_current_win(prev_win)
end,
pattern = '*',
group = vim.api.nvim_create_augroup("floatingQF", { clear = true })
})Useful if you want to transcribe something...
Write this line in your config (maybe in ftplugin/lilypond.lua ?) :
vim.api.nvim_create_user_command('Play', function(args)
local file = args.fargs[1]
if file then
require('nvls.player').open(file)
end
end, {
nargs = '*',
complete = 'file'
})Then run :Play /home/user/Documents/audio.wav
vim.keymap.set("v", "<leader>qp", ":lua<space>require('nvls.player').quickplayer()<cr>", { silent = true })Make a visual selection and press <leader>qp. It will open a player and (try) to play your selection
From niveK77pur : midi-input.nvim plugin is effectively a wrapper -- albeit a pretty advanced one -- around lilypond-midi-input, inspired by how Frescobaldi and Denemo handle MIDI input. The main goal is to allow using a MIDI keyboard to insert notes into your lilypond scores.
See https://wiki.termux.com/wiki/Touch_Keyboard
Add/Edit this lines in your ~/.termux/termux.properties :
extra-keys = [[ \
'ESC', \
{key: '/', popup: '<'}, \
{key: '-', popup: '_'}, \
{key: 'BACKSLASH', popup: '>'}, \
{key: '|', popup: '!'}, \
{key: '+', popup: '*'}, \
{key: UP, popup: PGUP}, \
'#', \
{key: '~', popup: '='}, \
{key: 'F5', popup: 'F2'}, \
{key: 'F6', popup: 'F3'}], \
\
[{key: ':', popup: ";"}, \
'TAB', \
{key: '{', popup: '('}, \
{key: '}', popup: ')'}, \
{key: '%', popup: '['}, \
{key: LEFT, popup: HOME}, \
{key: DOWN, popup: PGDN}, \
{key: RIGHT, popup: END}, \
{key: '"', popup: ']'}, \
{key: 'F4', popup: 'F1'}, \
'ALT'], \
\
['0','1','2','3','4','5','6','7','8','9','$'] \
]