Notepad++ autocompletion for Solarus

Started by linky, August 01, 2014, 05:15:39 PM

Previous topic - Next topic
Hi,

I didn't find around a notepad++ language file for Solarus (maybe it already exists somewhere ?) to have autocompletion. So i made one, as i think it can help at least the beginers to know easily the existing functions or methods, or just verify their parameters and of course to script more quickly long function's name. It is made from the solarus 1.2 doc website, so it should be uptodate so far (http://www.solarus-games.org/doc/latest/index.html).

Some people don't like much this kind of help, but it may be useful to some others, so here it is. It's the first one i make, so please excuse me if it is not made properly as it should or if it is incomplete. Also there is certainly some errors in it as it is difficult to test them all, so if you find errors by using it please don't hesitate to tell.

For those who don't know, you can activate autocompletion in notepad++ in the preferences (see picture 3).

As far i have understood, the file language must have the same name that the extension for which this language file should be applied. So the file is named "lua.xml" and has to be put in the plugins\APIs folder of notepad++. Normaly it is automatically recognized by notepad++ when you open a lua files as those of Solarus scripts.

Remark: It means that if you already have a more general lua.xml files applying to general lua language it wil replace it. If you then use lua files back for another environement that Solarus, you will have to change it again as lua is widely used for a lot of different applications.


Limitation:

1) First I have removed the begining "sol." extension on every functions and methods otherwise it gives too more results each time you begin with sol., so i thought it was not much effective.

2) In the case of showing the parameters of the functions (see picture 2), there is apparently a limitation in Scintilla/notepad++ autocompletion to recognize function's name separated with dot like "sol.main.load_settings". So only "load_settings" will be recognized.

To avoid this problem i have add those two versions (with and without the part with dot: "main.sol."). So the autocompletion mechanism propose the complete function "sol.main.load_settings" that allow to choose it without writing it all, and then after writing the "(" it show also the different parameters accesible for this function.

But this doesn't work when the function exists under different objects with different parameters:

For example timer.start should show :
sol.timer.start([context], delay, callback)

but will show:
sol.timer.start(context, menu, [on_top])

because only the end "start" function is recognized and taken from "sol.menu.start(context, menu, [on_top])" that comes first in the file, as again the begining "sol.main.timer." is not recognized.

I don't know if there is a solution to this problem, but it affects only a few functions, so it shouldn't be a big deal.

Thanks.


Nice!
I didn't even know there was completion in Notepad++.
Too bad it does not work well with functions in tables and with functions having the same name but in different tables.
Anyway, this looks very promising :)