martineausimon / nvim-lilypond-suite

Neovim plugin for writing LilyPond scores, with asynchronous make, midi/mp3 player, fast syntax highlighting, "hyphenation" function, and support for LaTex and Texinfo files
GNU General Public License v3.0
130 stars 11 forks source link

Player <F3> doesn't seem to be working. #9

Closed KaiVinter closed 1 year ago

KaiVinter commented 1 year ago

Hello! I managed to get pretty much everything working, but for some reason the shortcut F3 doesn't work. It gives me the next error:

callback: ...k/packer/start/nvim-lilypond-suite/lua/nvls/lilypond.lua:26: attempt to comp                    a
re nil with number
stack traceback:
        ...k/packer/start/nvim-lilypond-suite/lua/nvls/lilypond.lua:26: in function 'lilyPlayer'
        ...k/packer/start/nvim-lilypond-suite/ftplugin/lilypond.lua:26: in function <...k/packer/start/nvim-li
lypond-suite/ftplugin/lilypond.lua:24>

Screen Shot 2023-01-26 at 9 35 01 PM

I also can't seem to find the lilypond.lua the log says nor those directories.

I'm using MacOS Monterrey 12.6.1

martineausimon commented 1 year ago

Hello,

Thanks for your feedback, and sorry for this issue!

The file is lilypond.lua in nvim-lilypond-suite/lua/nvls/, and it seems that the function getLastMod() is the problem. This function checks if the compiled midi file is more recent than the last mp3 created by the plugin using the stat utility, and recreates an mp3 if necessary.

Can you check if stat is present on your system by checking the return of the following command?

which stat
KaiVinter commented 1 year ago

I just checked, it gives /usr/bin/stat, so it's there. It can totally be an error in my setup, because I'm kind of new using Neovim and some things might be above my understanding 😅 But it's also the only issue for now, so... I'm not sure

martineausimon commented 1 year ago

OK ! What's the output of :lua print(lilyAudioFile) ?

KaiVinter commented 1 year ago

When editing a .ly file: /Users/username/Documents/LilyPond/Test/Test.mp3 When no file open, just Neovim: nil

martineausimon commented 1 year ago

OK, and :

:lua print(tonumber(io.popen("stat -c %Y " .. lilyMidiFile):read()))

(when editing a .ly file, after compile)

KaiVinter commented 1 year ago

This appears:

Documents/LilyPond/Test/Test.ly                                                             1,1            All
stat: illegal option -- copen("stat -c %Y " .. lilyMidiFile):read()))
                         usage: stat [-FLnq] [-f format | -l | -r | -s | -x] [-t timefmt] [fi5,1           All
:                                                                                                   ni

Screen Shot 2023-01-27 at 5 08 40 PM

martineausimon commented 1 year ago

Ok thanks ! It look like stat command has not the same options in linux or osx. You can change stat -c %Y line 13 in lua/nvls/lilypond.lua with stat -f %m. I'll pull a fix tonight !

martineausimon commented 1 year ago

I just made an update, it should work now. Keep me informed, I do not have a mac to test it !

KaiVinter commented 1 year ago

Hello! I tried stat -f %m and it gave me 1674867642, which doesn't sound like something intuitive, but it looks like something works. I'll try your update

KaiVinter commented 1 year ago

Here again! I tried your update and now it shows [NVLS] Function not supported on your system (Which is not what I intended, but it's better than before 😆). However, using F3 does work (and it worked before the update) when doing a visual selection, so I'm not sure whether this actually doesn't work or it just needs something else

martineausimon commented 1 year ago

Haha sorry for that... I have made a mistake, fixed now ! Yes the player should work !

KaiVinter commented 1 year ago

Thank you! It does work now ✨