mirror of
https://github.com/tiyn/dotfiles.git
synced 2026-03-17 06:04:47 +01:00
nvim: added lilypond support
This commit is contained in:
57
.config/nvim/after/ftplugin/lilypond.lua
Normal file
57
.config/nvim/after/ftplugin/lilypond.lua
Normal file
@@ -0,0 +1,57 @@
|
||||
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()
|
||||
@@ -8,6 +8,7 @@ return {
|
||||
-- cmp sources
|
||||
'hrsh7th/cmp-buffer',
|
||||
'hrsh7th/cmp-path',
|
||||
'uga-rosa/cmp-dictionary',
|
||||
'lukas-reineke/cmp-under-comparator',
|
||||
-- luasnip
|
||||
{
|
||||
@@ -69,7 +70,8 @@ return {
|
||||
{ name = 'nvim_lsp' },
|
||||
{ name = 'luasnip' },
|
||||
{ name = 'path' },
|
||||
{ name = 'buffer' }
|
||||
{ name = 'buffer' },
|
||||
{ name = 'dictionary' }
|
||||
},
|
||||
formatting = {
|
||||
format = require("lspkind").cmp_format({
|
||||
|
||||
47
.config/nvim/lua/plugins/nvim-lilypond-suite.lua
Normal file
47
.config/nvim/lua/plugins/nvim-lilypond-suite.lua
Normal file
@@ -0,0 +1,47 @@
|
||||
return {
|
||||
"martineausimon/nvim-lilypond-suite",
|
||||
dependencies = "uga-rosa/cmp-dictionary",
|
||||
config = function()
|
||||
require("nvls").setup({
|
||||
lilypond = {
|
||||
mappings = {
|
||||
player = "<NOP>",
|
||||
compile = "<NOP>",
|
||||
open_pdf = "<NOP>",
|
||||
switch_buffers = "<NOP>",
|
||||
insert_version = "<NOP>",
|
||||
hyphenation = "<NOP>",
|
||||
hyphenation_change_lang = "<NOP>",
|
||||
insert_hyphen = "<NOP>",
|
||||
add_hyphen = "<NOP>",
|
||||
del_next_hyphen = "<NOP>",
|
||||
del_prev_hyphen = "<NOP>",
|
||||
},
|
||||
},
|
||||
player = {
|
||||
options = {
|
||||
fluidsynth_flags = {
|
||||
"/usr/share/soundfonts/FluidR3_GM.sf2",
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
local lily_dicts = {
|
||||
"~/.local/share/nvim/lazy/nvim-lilypond-suite/lilywords/keywords",
|
||||
"~/.local/share/nvim/lazy/nvim-lilypond-suite/lilywords/musicCommands",
|
||||
"~/.local/share/nvim/lazy/nvim-lilypond-suite/lilywords/musicFunctions",
|
||||
"~/.local/share/nvim/lazy/nvim-lilypond-suite/lilywords/articulations",
|
||||
"~/.local/share/nvim/lazy/nvim-lilypond-suite/lilywords/dynamics",
|
||||
}
|
||||
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
pattern = "lilypond",
|
||||
callback = function()
|
||||
require("cmp_dictionary").setup({
|
||||
paths = lily_dicts,
|
||||
})
|
||||
end,
|
||||
})
|
||||
end,
|
||||
}
|
||||
@@ -51,5 +51,6 @@ case "$file" in
|
||||
*\.tex) textype "$file" ;;
|
||||
*\.vpr) $vipercmd "$file" ;;
|
||||
*\.zsh) zsh "$file" ;;
|
||||
*\.ly) lilypond "$file" ;;
|
||||
*) sed 1q "$file" | grep "^#!/" | sed "s/^#!//" | xargs -r -I % "$file" ;;
|
||||
esac
|
||||
|
||||
Reference in New Issue
Block a user