Making a nice toolchain for developing Renoise Tools on MacOSX

Hi, has anybody found a nice way to use modern IDE features like auto-completion suggestions and jump to definition for editing lua scripts?

I have tried getting Sublime, VS Code, and Vim to work the way i want, but none of them are 100%. Actually, Vim is pretty close but i keep forgetting how i have it configured when i take a break from coding, and the keyboard heavy work style isn’t ideal for my space, i need more mouse.

Both VS Code and Sublime have nice modern features built in, but they don’t work too well with lua, so i’ve been searching out packages and no one single package does it all. I have to have a combo of various ones for different things like linting and tags, using command line back end tools like luacheck. Sublime has trouble finding some of my methods. Whereas VS code just wont jump to definitions at all (at least last time i was using it).

I’m going to crack on using Sublime for the moment, have got the luacheck linter running ok, and some ctags set up which seems to be doing the job in vim and possibly sublime too, honestly can’t remember how i did all this. Plus it’s easy to read the code on my screen.

Would be good to hear ideas.

2 Likes

Got back to renoise-scripting recently and at first I was using QtCreator, it has only decent syntax highlighting, no navigation.
But I noticed that Geany allows jumping to function definitions in the RMB context menu (I think only if in same file) and it also outlines functions in the side panel.

Google also found me this ZeroBrane FOSS IDE, I have not tried it myself, may be worth.
Alas for code completion it appears to require a hand-made definition file, not sure whether it also takes regular lua files as given by the Renoise API.

This is all I got for you. I am also a vim fan but I used to spend crazy amounts on he “tooling” to customize it but for programming I always ended up using some dedicated IDE in the end. My choices were QtCreator for C++ and Wing IDE for Python.

image

Hi, thanks for joining in. I was thinking of writing a language plugin for ZeroBrane with all the xrnx API objects, but actually, it’s just too much work and i’d rather be making tools with that time. Otherwise, it’s a nice piece of software, but i just like the minimalist style of Sublime too much to switch over. I feel spoiled by how slick it is. The others i’ve never heard of, but i think i’d have the same reaction to them as with ZeroBrane. Also, something about the way Sublime renders text just makes my eyes happy. VS Code is close second, but a bit weird in places. Then Vim for its total no frills work ethic. The badwolf colourscheme is really nice to look at, i find.

So far i have got a pretty good set up on Sublime 3, but the thing i’m really missing is a symbol browser like in that screen shot. I installed the ctags package last night, and it seems to work ok with my luabind definitions that i made in universal ctags. It reads the class parameters correctly. Will need to test it a bit more. Willing to share them if anyone is interested. I got the tag definitions pretty close now, and they work on the c++ like class-method style that i’m using for the xrnx tools. I can get a list of the symbols in the ‘palette’, but it’s not as nice as having a sidepane, as the list blocks out the code i’m working on! Pretty annoying. Looks like a feature people have been asking for for 10 years, and still nothing, so i guess it’s not happening any time soon. Actually, that command palette system really gets on my tits, it’s not as clever as it thinks it is.

Just rambling now. I wish Vim looked as hot as Sublime and used more mouse…

VSCode is very good, for LUA, too. And free. EDIT: You already mentioned it. I think VSCode so far is the best option.

Yes, i like VS Code, but for some reason cannot get ‘jump to definition’ to work for my projects. It just doesn’t respond at all when i hit F12. I think it has a problem with the way luabind obscures the normal table style of lua, plus having multiple layers of nested tables and references. I think if i removed all the ‘class’ stuff and just went with a normal metatable for making objects then maybe it would function, but i like the syntax luabind gives you, simple as it is.

Is there any way I can get vscode to recognise the renoise lua stuff, so I can, for instance, get auto-complete on “renoise.” ?

I use luacheck to do it, with the following in my .luacheckrc file -

max_line_length = false
allow_defined_top = true
ignore = {"113", "131", "211"}
globals = {    
    renoise = {read_only = false, other_fields = true},
    song = {read_only = false, other_fields = true},
    tool = {read_only = false, other_fields = true},
    push = {read_only = false, other_fields = true},
    class = {},
    Push = {read_only = false, other_fields = true},
    State = {read_only = false, other_fields = true},
    Mode = {read_only = false, other_fields = true},
    Midi = {read_only = false, other_fields = true}
}
std = "lua51c"

Not sure how to set it up on windows, but there’s probably a way. You of course don’t need the last 4 fields in the globals, as they are unique to my Push tool, but the other stuff works well i found. The ignores are to get rid of annoying warnings which don’t matter (can’t remember which ones they are now).

EDIT: Actually, luacheck may only be the linter, i think you need an autocomplete tool to get the pop-ups. I stopped using vs code because i couldn’t get it to work well with lua. The jump to definition macro never worked and other bits weren’t perfect. I have a nice Vim setup that works great now.

Thanks! I was actually gonna have a look at your push tool so that’s super helpful :slightly_smiling_face:

Welcome!

I actually just realised that i haven’t updated the luacheck file for ages so it might be missing a few classes. But should work for the most part.

Also having Universal Ctags installed can help with linters/parsers. I’m not sure if there’s support in vs code, but there could be a plugin for it.

My ctags definitions file is as follows (it’s not perfect and i’m not sure i got it right exactly, but it works well for me in vim):

--kinddef-lua=c,class,classes
--kinddef-lua=m,member,members
--kinddef-lua=f,function,functions
--kinddef-lua=t,table,tables

#set basic function captures
--regex-lua=/^[ \t]*function[ \t]+([A-Za-z_][A-Za-z0-9_]*)[ \t]*\([^)]*\)[ \t]*/\1/f,function/
--regex-lua=/^[ \t]*([A-Za-z_][A-Za-z0-9_]*)[ \t]*=[ \t]*function[ \t]*\([^)]*\)[ \t]*/\1/f,function/
#add class and class method captures (only one class per file with a single level function scope)
--regex-lua=/^class[ \t]+['"]([A-Za-z_][A-Za-z0-9_]*)['"][ \t]*$/\1/c,class/{scope=push}
--regex-lua=/^function[ \t]+[A-Za-z_][A-Za-z0-9_]*[:.]([A-Za-z_][A-Za-z0-9_]*)[ \t]*\([^)]*\)[ \t]*/\1/f,function/{scope=push}
--regex-lua=/^end[ \t]*///{scope=pop}{placeholder}

Note, this will only work with the Universal Ctags fork, not exuberant ctags, as it uses extensions to the format introduced in Universal.

2 Likes

i would love to move to Sublime Text from the horrendous (!!!) Scripting Tool Editor that Renoise provides which for macOS is just no. it irks me to use it. I’m sure I’d be way faster with Sublime Text.
but what i’m seeing is that it does not seem to care for text replacement - i use a lot of macOS Keyboard text replacement stuff, and was thinking of adding renoise.song().selected_instrument_index and renoise.song().selected_sample_index there but if sublime doesn’t support that, then it’s kinda sad.

but if you save a lua script, does it get auto-reloaded into Renoise?

From my point of view the Renoise scripting tool is the best option for programming Lua tools for Renoise. The only thing missing is that it does not have its own zoom for the text (and some secondary things). But it is better to use it because you work in sync with Reniose to test the code, and that is very immediate. With a good color theme, nothing else is necessary.

i need cmd-cursor keys to work. they don’t.
that’s a major dealbreaker.
also the same for “Move focus to next window”. that one is in Renoise, but missing from the Scripting Tool & Editor.

That’s what the line _AUTO_RELOAD_DEBUG = true is supposed to do, but i’ve found it unreliable at best.

In Sublime i set up a toolchain using an LSP to do lua completion and then use luacheck for linting, with some custom XRNX patterns in the config. I can write up a detailed toolchain guide for both Sublime and Vim if anyone is interested. But it will take a while as i set it all up years ago and have forgotten most of the details because it works pretty well for XRNX dev now. The Vim one is much more complex and requires the use of universal-ctags. Both use the same luacheck setup though.

It’s truly horrible when you’re used to Vim or Sublime. So many quality of life features are missing, it’s like using Notepad on Windows 98. You can quite easily use an external editor and switch back and forth to Renoise to test. That’s what i do and it’s not too bad.

@cupcake, From sublime text can you somehow control the Terminal of the Renoise scripting tool?

It would be great to be able to use an external text editor, with zoom, and other extras. But it is necessary to constantly test the tool that you build (trial and error) and for that it is necessary to use the terminal massively, where you can print many useful things.

Is there some way to implement that in sublime text. I have another text editor, notepad++. But to program tools I always use the Renoise editor so I can test the tool (autoreload debug) and use the terminal. If the text tool had its own zoom, I wouldn’t ask for anything more, because the API documentation is present, the changing of text colors as well and the detection of errors.

I should also say that I know many parts of the API by heart. In most cases I don’t need suggestions, and I always start my programming projects with a “half-prepared” template.

What do you usually need as extras for the text editor? Something like text autocompletion, or suggestions?

I am particularly interested in this whole topic. Any external text tool that could be integrated with the terminal would be very interesting. But I have never tried this.

The terminal part of the scripting window is something else. I thought you were talking about using the built-in text editor. It’s really not much slower having a second window open with an external text editor, then switching focus to Renoise for running tests.

But there’s probably a fancy way to output messages from the Renoise lua instance via a tool like luasocket to the system lua running in your desktop terminal.