5

Some time ago I found a git repository with a Lilypond's syntax extension for VSCode. I looked it up within VSCode's extension finder, and it was there as well. And this extension is really useful, but I haven't found a way to use it directly with Lilypond (having the possibility to use the keyboard shortcuts for Save and Compile (Cmd + S & Cmd + R in my case) as well as the PDF opening with Preview (on Mac) without having to change between the three programs.

Is this possible? I looked it up for quite a while, but I didn't seem to get an idea of what was being explained (mainly because I don't have any knowledge about programming nor the use of the command line).

1
  • 2
    Did you follow the setup directions? It sounds like the extension needs additional setup by you. I suspect the extension is trying to use functionality lilypad provides via the command-line, but you haven't added lilypad to your path, and so it can't compile. Each OS has a 'global variable' (typically called 'path') that a program called a command-line will search when it's told to run other programs. For example when you run 'dir' in cmd.exe, it uses the path to find the 'dir' program and then execute it.
    – Derek E
    Jan 7, 2021 at 6:48

2 Answers 2

7

I just set this up on my machine so that I could verify things worked as expected. (Had to install VSCode as it looks like there's no such LilyPond plugin for regular VS.)

I installed the following software:

  • VSCode
  • LilyPond
  • python-ly (via pip)
  • VSLilyPond (VSCode extension)
  • vscode-pdf (VSCode extension)

This software allows me to point VSCode at a folder and:

  • edit .ly files with VS goodies
  • save .ly files, which automatically compiles them into pdfs (without logs)
  • view the generated pdf music notation in VSCode.

I haven't tried out the midi functionality yet, but things so far seem to be in working order.

I mentioned the following in a comment on the OP, but it's important to follow these setup instructions for VSLilyPond. They will tell you that LilyPond should be setup for command-line usage (i.e. the folder that the lilypond executable lives in needs to be added to your path). Instructions for doing that can be found by clicking on your operating system here.

I already had python installed and on my path, but that would be an additional desired setup for installing python-ly via pip. The extension says python-ly is required for the extension "LilyPond Formatter", which was automatically added to VSCode when I installed VSLilyPond.

8
  • Thank you Derek. Now I’m getting an idea of how to work with this. I just have one question. Should I Change the default Python 2 to Python 3? I had both installed before, I remember installing Python 3, but I’m not sure if this is necessary/better/recommended.
    – Kai Vinter
    Jan 10, 2021 at 21:43
  • I wouldn't bother if you can get away with it. Reason is it might break something and if you aren't inclined to fix it, it might stay broken which would be a shame. This link has instructions for how to point LilyPond Formatter at python3 if it's not default. You can check what's default via the command-line by entering 'python --version' (no quotes). Typically, when both 2 and 3 are installed, there will be a python3 on the path, so you could also test that by entering 'python3 --version'.
    – Derek E
    Jan 12, 2021 at 0:03
  • But if it is an old (no longer in use) install of python2 and/or you are inclined to fix things (assuming that's possible), then I'd go with python3. On my windows machine I only have python3 installed. On my Linux machine, both exist (due to dependencies) and I either alias to python3 or just type python3, I forget which :P. The reason I suggest caution in my first comment is that you do have python2 installed and that might have been a dependency for all I know. Hope that helps.
    – Derek E
    Jan 12, 2021 at 0:11
  • 2
    Hey I am the author of VSLilyPond--I'm looking into to making this more seamless! Thanks for the very detailed answer.
    – Lh Lee
    May 9, 2021 at 18:47
  • 2
    @DerekE you can actually find the compilation logs in the Output section :) Think I should document this, haven't been actively working on the extension these days.
    – Lh Lee
    May 9, 2021 at 19:07
2

I am the author of VSLilyPond--while @DerekE has covered the question well, I've pushed out some updates that now lets users bypass the python-ly and vscode-pdf installations. The setup instructions were updated accordingly as well.

There's a nice guide here with even more details

Have fun!

2
  • 1
    Thank you for reviewing my questions, I'm already using your PDF Previewer and it's just delicious. I didn't think this would happen this quick.
    – Kai Vinter
    Jul 27, 2021 at 23:29
  • Hi, I encountered an issue when using VSLilyPond, the pdf(in split view in vscode) not auto reloading. how can I make it auto reload so I can see the preview right after I press command+s on my Mac?
    – Willis
    Dec 5, 2021 at 11:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.