1

Whatever the setup I use for coding in Lua is always the same thing: autocompletion works for the standard libraries but not for the 3rd parties or my own libraries.

I tried ZeroBrane studio, VSCode with Lua plugin and Vim with lua ftplugin, exact same behaviour in all 3. I start typing a standard library symbol such as

io.w

And I do get the autocompletion popup showing everything in the io module, and showing the closest method to io.w which would be io.write, with the signature and documentation.

Now I try a 3rd party or my own library such as

require("wx"); wx.

or

require("my_module"); my_module.

Either nothing happens at all, or I get a warning "undefined" on the module name. If I run the code with the interpreter, it does work. It will call the function in the module just fine. But in the editor, warning and no autocompletion.

Am I missing something?

Egor Skriptunoff
  • 23,359
  • 2
  • 34
  • 64
aganm
  • 1,245
  • 1
  • 11
  • 30

1 Answers1

1

wxwidgets API comes prepackaged with ZeroBrane Studio, but it needs to be explicitly enabled (you can add api = {"wxwidgets"} to the config file to do that; see Custom APIs section in the documentation). Any other (non-packaged) API would need to be added to the IDE as documented here. There are several popular APIs already provided as plugins; for example, for Redis, Urho3d, openRA and others.

Paul Kulchenko
  • 25,884
  • 3
  • 38
  • 56
  • Is it normal that I don't have any autocompletion for my own module which is right there in a lua file? I would expect the autocompleter to give me hints for my own code as it would in other ides, like C++ in Visual Studio for example. I'm just confused why I don't have any completion, is it normal in lua world to not have completion for your own code? – aganm Mar 05 '20 at 22:15
  • @aganm - Generally, it's impossible to deduce which functions are exported by your module just by looking at module's source code without executing it. – Egor Skriptunoff Mar 06 '20 at 00:06
  • @EgorSkriptunoff How does the lua standard library gets completion though? Do you know how I can make my code behave the same completion wise? Do I need to add doc files somewhere? – aganm Mar 06 '20 at 00:39
  • @aganm - Usually, for autocompletion to work, you have to provide list of functions manually as a file of some specific format (format is different in different IDEs). Read the links Paul has given to you. – Egor Skriptunoff Mar 06 '20 at 08:58