Old 07-09-2018, 09:14 AM   #1
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
Default Reaper tools for Visual Studio Code

After ausbaxter kindly put together a set of snippets for the Reaper API, I figured it would be handy to have one place for collecting any Reaper-related tools/extensions/etc for Visual Studio Code. So, well, here it is:

https://github.com/jalovatt/reaper-vs-code
  • Autocomplete snippets for the API, covering Lua, EEL, and Python:


  • A handful of my own snippets for common tasks such as a ReaPack header, and a wrapper for ShowConsoleMsg

  • Basic language support and syntax highlighting for EEL and Walter:


Installation instructions can be found in each folder's README.

Further contributions are more than welcome - better language definitions, more snippets, etc. PM me, make a pull request on the repo, whatever you want.

Enjoy!
__________________
I'm no longer using Reaper or working on scripts for it. Sorry. :(
Default 5.0 Nitpicky Edition / GUI library for Lua scripts / Theory Helper / Radial Menu / Donate
Lokasenna is offline   Reply With Quote
Old 07-23-2018, 09:00 AM   #2
tronce
Human being with feelings
 
Join Date: Oct 2017
Posts: 18
Default

thank you very much Lokasenna!
tronce is offline   Reply With Quote
Old 07-25-2018, 09:55 AM   #3
tack
Human being with feelings
 
tack's Avatar
 
Join Date: Jan 2014
Location: Ontario, Canada
Posts: 1,618
Default

Thanks for EEL syntax highlighting! I had been using C# which is kinda-sorta ok enough to be useful, but obviously proper support for the language is much better.

Cheers!
tack is offline   Reply With Quote
Old 07-26-2018, 01:00 PM   #4
Ozman
Human being with feelings
 
Join Date: Feb 2015
Posts: 753
Default

Anyone know how to do quick lua formatting (indentation) in VS Code for some minified lua?
Ozman is offline   Reply With Quote
Old 07-26-2018, 06:28 PM   #5
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
Default

What happens if you open the Command Palette and find "Format Document"? Do you have a Lua extension (I like "vscode-lua")?
__________________
I'm no longer using Reaper or working on scripts for it. Sorry. :(
Default 5.0 Nitpicky Edition / GUI library for Lua scripts / Theory Helper / Radial Menu / Donate
Lokasenna is offline   Reply With Quote
Old 07-31-2018, 06:46 AM   #6
Ozman
Human being with feelings
 
Join Date: Feb 2015
Posts: 753
Default

Quote:
Originally Posted by Lokasenna View Post
What happens if you open the Command Palette and find "Format Document"? Do you have a Lua extension (I like "vscode-lua")?
I get at the bottom right:
There is no document formatter for 'lua'-files installed.
----------------

Edit..
Ok, installing vscode-lua and running "Format Document" with text selected works.

Much thanks, Lokasenna.

----------------

.. VS Code is my new text editor. Still getting the hang of it.
Ozman is offline   Reply With Quote
Old 07-31-2018, 07:35 AM   #7
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
Default

While we're on the topic of extensions, Bracket Pair Colorizer is incredibly helpful.
__________________
I'm no longer using Reaper or working on scripts for it. Sorry. :(
Default 5.0 Nitpicky Edition / GUI library for Lua scripts / Theory Helper / Radial Menu / Donate
Lokasenna is offline   Reply With Quote
Old 07-31-2018, 08:13 AM   #8
Ozman
Human being with feelings
 
Join Date: Feb 2015
Posts: 753
Default

Quote:
Originally Posted by Lokasenna View Post
While we're on the topic of extensions, Bracket Pair Colorizer is incredibly helpful.
Ya know what... That is so true.
Matching color brackets can be very helpful!

Thanks again, Lokasenna!
Ozman is offline   Reply With Quote
Old 08-02-2018, 05:36 AM   #9
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,096
Default

I'm using these snippets happily. Thank you.
nofish is offline   Reply With Quote
Old 08-02-2018, 07:20 AM   #10
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
Default

Are parameter reminders working for anyone else? They were for me, but I feel like the most recent Code update made them go away.

Side note: There's a known Code bug with autocomplete triggers that contain a period, like reaper. - I think the forthcoming update has a fix.
__________________
I'm no longer using Reaper or working on scripts for it. Sorry. :(
Default 5.0 Nitpicky Edition / GUI library for Lua scripts / Theory Helper / Radial Menu / Donate
Lokasenna is offline   Reply With Quote
Old 08-07-2018, 11:58 PM   #11
ausbaxter
Human being with feelings
 
Join Date: Apr 2016
Posts: 39
Default

Hey all, I finally got around to fixing some of the issues when I first converted the api. Lokasenna, I submitted a pull request not too long ago, should be a much nicer conversion.

Fixed:
Some single letter variables not showing up (x, y, etc).
Optional parameters are now notated with brackets
String quotations are now outside the tabable parameter area.
No more broken descriptions.
ausbaxter is offline   Reply With Quote
Old 08-08-2018, 04:15 AM   #12
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
Default

Cheers, merged.
__________________
I'm no longer using Reaper or working on scripts for it. Sorry. :(
Default 5.0 Nitpicky Edition / GUI library for Lua scripts / Theory Helper / Radial Menu / Donate
Lokasenna is offline   Reply With Quote
Old 08-15-2018, 02:38 PM   #13
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
Default

Another handy extension (maybe I should keep a list in the OP) for anyone dual-booting or switching between different machines: https://marketplace.visualstudio.com...-settings-sync

It uses a Github Gist to store all of your settings and snippets so you can (for instance) save them on Windows and grab them on Linux.
__________________
I'm no longer using Reaper or working on scripts for it. Sorry. :(
Default 5.0 Nitpicky Edition / GUI library for Lua scripts / Theory Helper / Radial Menu / Donate
Lokasenna is offline   Reply With Quote
Old 09-05-2018, 06:02 AM   #14
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Location: Black Forest
Posts: 5,054
Default

Just wanted to say "thank you" for these snippets, very useful!
And you made me switch to VSC from Notepad++
__________________
My Reascripts forum thread | My Reascripts on GitHub
If you like or use my scripts, please support the Ukraine: Ukraine Crisis Relief Fund | DirectRelief | Save The Children | Razom
_Stevie_ is offline   Reply With Quote
Old 10-02-2018, 05:00 AM   #15
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,096
Default

Just a little heads up of something that gave me a bit of head scratching, maybe useful for someone else...

I wondered why using Lua bitwise operators (&, |, ...) in Code (using vscode-lua extension) always showed an error.
Turned out default Lua version is set to 5.1 and needs to be set to 5.3.

nofish is offline   Reply With Quote
Old 11-15-2018, 08:50 AM   #16
ThrashJazzAssassin
Human being with feelings
 
ThrashJazzAssassin's Avatar
 
Join Date: Oct 2010
Location: Scotland
Posts: 422
Default

Thanks for making a start on this Lokasenna. There's still a lot missing, so to help out, I thought I'd go through some jsfx in the Reaper IDE and record what the colours I see. Not an exhaustive list.

I have no VS Code extension authoring experience, but I'll look in to it. May be a while before I can make a contribution.

Dark Blue
Comments✔


Cyan
:?✔
URL's e.g. http://www.cockos.com
in_pin:
out_pin:
slider1:
@init
@slider
@serialize
@block
@sample
@gfx
filename:
<>=()=+-;[]{}|.
options:


Blue
function✔
local✔
loop✔
this.
instance
globals


Green
#numbers e.g. 1024✔


Pink
"strings"✔


yellow
custom function name allocation✔
custom function calls


Bold yellow
built-in function calls:
midirecv
midisend
memset
gfx_blitext
gfx_getpixel
gfx_rectto
gfx_printf
gfx_set
gfx_setfont
floor
gfx_drawnumber
gfx_drawchar
gfx_lineto
gfx_rectto
min
max
abs


Red
Built-in variables (reserved):
mouse_cap
mouse_x
mouse_y
mouse_wheel
ext_noinit
beat_position
ts_num
play_state
srate
gfx_h
gfx_x
gfx_y
gfx_a
gfx_g
gfx_b
gfx_r
gfx_w
__________________
TJA MIDI JSFX | REAPER-OSC-panels | erthoide
ThrashJazzAssassin is online now   Reply With Quote
Old 11-29-2018, 12:21 PM   #17
inscript
Human being with feelings
 
Join Date: Aug 2018
Posts: 19
Default

I'm new to VSCode. I'm attempting to use a portable installation of VS and I've cloned the folder into Data/Code/Extensions, and pasted the file association into my settings, but I still can't seem to get an option in the bottom left corner for EEL/JSFX file formatting. Also, does anyone know what the acceptable jsfx extension is (assuming its .jsfx), because file associations in VS won't work unless I name my saved effects with their extension, correct?
inscript is offline   Reply With Quote
Old 02-16-2019, 07:44 PM   #18
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
Default

Quote:
Originally Posted by inscript View Post
I'm new to VSCode. I'm attempting to use a portable installation of VS and I've cloned the folder into Data/Code/Extensions, and pasted the file association into my settings, but I still can't seem to get an option in the bottom left corner for EEL/JSFX file formatting. Also, does anyone know what the acceptable jsfx extension is (assuming its .jsfx), because file associations in VS won't work unless I name my saved effects with their extension, correct?
This is a ridiculously late reply, but the problem with JSFX is that they don't have a file extension at all; that's why you have to paste that file association code into your settings. It just tells VS Code that any file under your Reaper/Effects folder (where the JSFX all live) is a JSFX.
__________________
I'm no longer using Reaper or working on scripts for it. Sorry. :(
Default 5.0 Nitpicky Edition / GUI library for Lua scripts / Theory Helper / Radial Menu / Donate
Lokasenna is offline   Reply With Quote
Old 02-16-2019, 08:02 PM   #19
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
Default

Quote:
Originally Posted by ThrashJazzAssassin View Post
Thanks for making a start on this Lokasenna. There's still a lot missing, so to help out, I thought I'd go through some jsfx in the Reaper IDE and record what the colours I see. Not an exhaustive list.
Sorry for such a late reply, and thanks for doing that. I've tossed your list into an issue on the project repository: https://github.com/jalovatt/reaper-vs-code/issues/3

I'm (hopefully) starting to get back into Reaper stuff, so with luck I might be able to take a crack at it. In the meantime, if you're at all interested it's not super complicated:

- in the folder where you installed the EEL2 extension, open syntaxes/eel2.tmLanguage.json. The file is really just a series of tags and regular expressions to tell it what a function is, or what your language's keywords are, etc.

- In VS Code, open the command palette (Cmd+Shift+P or F1, I think) and choose "Inspect TM Scopes". This will show you exactly what the language parser sees for the text at your cursor location.

- Saving the file should automatically update the coloring in VS Code. If it doesn't, re-opening the file or reloading the window will.

- If you do make any progress, you can either submit a pull request with your changes on the project repo or just PM me and I can handle it myself.

Cheers.
__________________
I'm no longer using Reaper or working on scripts for it. Sorry. :(
Default 5.0 Nitpicky Edition / GUI library for Lua scripts / Theory Helper / Radial Menu / Donate
Lokasenna is offline   Reply With Quote
Old 06-24-2019, 05:01 AM   #20
n0ne
Human being with feelings
 
Join Date: Jun 2014
Posts: 152
Default

Thanks so much this is amazing! Can't believe I'm only finding this now
n0ne is offline   Reply With Quote
Old 08-27-2019, 03:39 AM   #21
nikolalkc
Human being with feelings
 
nikolalkc's Avatar
 
Join Date: Feb 2017
Location: Belgrade, Serbia
Posts: 338
Default

Quote:
Originally Posted by Lokasenna View Post
After ausbaxter kindly put together a set of snippets for the Reaper API, I figured it would be handy to have one place for collecting any Reaper-related tools/extensions/etc for Visual Studio Code. So, well, here it is:

https://github.com/jalovatt/reaper-vs-code
  • Autocomplete snippets for the API, covering Lua, EEL, and Python:


  • A handful of my own snippets for common tasks such as a ReaPack header, and a wrapper for ShowConsoleMsg

  • Basic language support and syntax highlighting for EEL and Walter:


Installation instructions can be found in each folder's README.

Further contributions are more than welcome - better language definitions, more snippets, etc. PM me, make a pull request on the repo, whatever you want.

Enjoy!
OMG OMG OMG!!!
Thank you for this, you don't know how useful this is for me!
YOU ARE AWESOME!
nikolalkc is offline   Reply With Quote
Old 09-26-2019, 07:25 PM   #22
dsyrock
Human being with feelings
 
dsyrock's Avatar
 
Join Date: Sep 2018
Location: China
Posts: 565
Default

Hi, I'm wondering why when I type "oncommand" in a lua script, it shows "Main_OnCommand" but not "reaper.Main_OnCommand" ?
dsyrock is online now   Reply With Quote
Old 09-26-2019, 08:20 PM   #23
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
Default

Not sure.



VS Code has some settings for how it handles code snippets, but I don't remember if any of them would affect that.
__________________
I'm no longer using Reaper or working on scripts for it. Sorry. :(
Default 5.0 Nitpicky Edition / GUI library for Lua scripts / Theory Helper / Radial Menu / Donate
Lokasenna is offline   Reply With Quote
Old 09-27-2019, 07:11 AM   #24
solger
Human being with feelings
 
solger's Avatar
 
Join Date: Mar 2013
Posts: 5,844
Default

Quote:
Originally Posted by dsyrock View Post
Hi, I'm wondering why when I type "oncommand" in a lua script, it shows "Main_OnCommand" but not "reaper.Main_OnCommand" ?
Just to clarify:
  • Did you copy the reaper-api.code-snippets file (from the snippets folder of the github download linked in post #1) to the appropriate folder?
  • And what operating system are you using in this case?
__________________
ReaLauncher
solger is offline   Reply With Quote
Old 09-28-2019, 12:26 AM   #25
dsyrock
Human being with feelings
 
dsyrock's Avatar
 
Join Date: Sep 2018
Location: China
Posts: 565
Default

Quote:
Originally Posted by solger View Post
Just to clarify:
  • Did you copy the reaper-api.code-snippets file (from the snippets folder of the github download linked in post #1) to the appropriate folder?
  • And what operating system are you using in this case?
Hi, thanks for your reply. I've fixed this issue, but came across a new one.

Can I remove the first option, and left others there? And what does the "abc" icon mean?
Attached Images
File Type: png 微信图片_20190928141156.png (13.2 KB, 2215 views)
dsyrock is online now   Reply With Quote
Old 09-28-2019, 05:13 AM   #26
solger
Human being with feelings
 
solger's Avatar
 
Join Date: Mar 2013
Posts: 5,844
Default

Quote:
Originally Posted by dsyrock View Post
Can I remove the first option, and left others there? And what does the "abc" icon mean?
The icons represent different types of IntelliSense completions: in this case 'abc' for words and the 'rectangle' for snippet prefixes.

It's possible to disable the 'abc' word ones:
  • by unchecking the Editor: Word Based Suggestion option in the Text Editor > Suggestions page of the settings (File > Preferences > Settings) **
  • or by adding the "editor.wordBasedSuggestions": false line in the settings.json file directly
More details here:

** As a side note: it's a good strategy in general to use the search bar at the top of the settings page to find specific options more quickly (in this case, for instance, by searching for 'suggestion' or 'intellisense'):
https://code.visualstudio.com/docs/g...ettings-editor
__________________
ReaLauncher

Last edited by solger; 09-28-2019 at 05:48 AM.
solger is offline   Reply With Quote
Old 09-28-2019, 06:29 AM   #27
dsyrock
Human being with feelings
 
dsyrock's Avatar
 
Join Date: Sep 2018
Location: China
Posts: 565
Default

[QUOTE=solger;2186176]It's possible to disable the 'abc' word ones:
  • by unchecking the Editor: Word Based Suggestion option in the Text Editor > Suggestions page of the settings (File > Preferences > Settings) **
  • or by adding the "editor.wordBasedSuggestions": false line in the settings.json file directly

Big help for me, thank you solger!
dsyrock is online now   Reply With Quote
Old 10-05-2019, 06:49 AM   #28
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,913
Default

Thanks for the reaper-api snippets, I finally gave VS Code a try (portable install), cool!

Has anyone made snippets for js_ReaScriptAPI?
I'm making a little utility (vb.net) that parses and builds a snippet for me.
Thanks!

Last edited by Edgemeal; 10-05-2019 at 12:25 PM.
Edgemeal is offline   Reply With Quote
Old 10-05-2019, 09:54 AM   #29
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
Default

Ausbaxter made the snippets with a script that parsed through Reaper's generated API docs, which will include the JS extension if you have it installed. I don't have the script, otherwise I'd be happy to keep things more up-to-date.
__________________
I'm no longer using Reaper or working on scripts for it. Sorry. :(
Default 5.0 Nitpicky Edition / GUI library for Lua scripts / Theory Helper / Radial Menu / Donate
Lokasenna is offline   Reply With Quote
Old 10-05-2019, 10:04 AM   #30
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,913
Default

Thanks, I was wondering if that was possible, didn't look into parsing the html (yet).

Last edited by Edgemeal; 10-05-2019 at 07:19 PM.
Edgemeal is offline   Reply With Quote
Old 10-05-2019, 10:30 AM   #31
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
Default

PMed ausbaxter to see if I can get the script he was using.
__________________
I'm no longer using Reaper or working on scripts for it. Sorry. :(
Default 5.0 Nitpicky Edition / GUI library for Lua scripts / Theory Helper / Radial Menu / Donate
Lokasenna is offline   Reply With Quote
Old 10-05-2019, 07:18 PM   #32
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,913
Default

That be great!

Edit, I parsed the html so all code comments are now included, but still only for Lua.

Last edited by Edgemeal; 10-14-2019 at 08:03 PM.
Edgemeal is offline   Reply With Quote
Old 10-06-2019, 01:24 AM   #33
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Location: Black Forest
Posts: 5,054
Default

Weee, thanks Edgy!
__________________
My Reascripts forum thread | My Reascripts on GitHub
If you like or use my scripts, please support the Ukraine: Ukraine Crisis Relief Fund | DirectRelief | Save The Children | Razom
_Stevie_ is offline   Reply With Quote
Old 10-06-2019, 07:49 AM   #34
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,913
Default

Are there any settings (font size, wordwrap,etc) for that code info area? It breaks words and can be hard to read.
Edgemeal is offline   Reply With Quote
Old 10-06-2019, 08:21 AM   #35
solger
Human being with feelings
 
solger's Avatar
 
Join Date: Mar 2013
Posts: 5,844
Default

Quote:
Originally Posted by Edgemeal View Post
Are there any settings (font size, wordwrap,etc) for that code info area? It breaks words and can be hard to read.
Seems like it's currently not possible natively: https://github.com/microsoft/vscode/issues/29126

But the Custom CSS extension looks interesting (haven't tried it myself yet): https://stackoverflow.com/questions/...cription-popup
__________________
ReaLauncher
solger is offline   Reply With Quote
Old 10-06-2019, 08:30 AM   #36
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,913
Default

Added code by ShenHongFei, (/* suggest-widget size */)
https://github.com/microsoft/vscode/issues/53565

At least snippet and description popups are wider now, that helps!

@solger, looks like a similar workaround.

EDIT, with the newer versions of VS CODE you can now just resize the description window with mouse.

Last edited by Edgemeal; 04-10-2021 at 11:38 AM.
Edgemeal is offline   Reply With Quote
Old 10-06-2019, 12:21 PM   #37
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,913
Default

Quote:
Originally Posted by _Stevie_ View Post
Weee, thanks Edgy!
Updated (see post #32), preserved line breaks in code comments, previously I removed them and they were just a single line.
Edgemeal is offline   Reply With Quote
Old 10-06-2019, 05:22 PM   #38
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Location: Black Forest
Posts: 5,054
Default

Awesome, getting it, thanks!
__________________
My Reascripts forum thread | My Reascripts on GitHub
If you like or use my scripts, please support the Ukraine: Ukraine Crisis Relief Fund | DirectRelief | Save The Children | Razom
_Stevie_ is offline   Reply With Quote
Old 10-13-2019, 09:28 AM   #39
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,913
Default

Whats up with the reaper-api.code-snippets?, their not even complete. Example I just tried adding GetFocusedFX and all I get is,
Code:
reaper.GetFocusedFX()
That isn't very helpful at all, I was expecting the whole function text with the return params like this,
Code:
integer retval, number tracknumber, number itemnumber, number fxnumber = reaper.GetFocusedFX()
That's how I did the JS_API, Isn't that what you'd expect?
Or maybe I have old snippet file or something?

Last edited by Edgemeal; 10-13-2019 at 09:36 AM.
Edgemeal is offline   Reply With Quote
Old 10-13-2019, 09:42 AM   #40
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Location: Black Forest
Posts: 5,054
Default

No, you are right, they are indeed missing :/
__________________
My Reascripts forum thread | My Reascripts on GitHub
If you like or use my scripts, please support the Ukraine: Ukraine Crisis Relief Fund | DirectRelief | Save The Children | Razom
_Stevie_ is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 11:17 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.