Page 1 of 1

Lua API Completer for Vim

PostPosted: Fri Aug 05, 2016 19:05
by DraggonFantasy
Hi :)
I'm very impressed by Minetest, it's a great game (greatest open source game I've ever seen)! I decided to make some mods for it, but I haven't found any way to auto-complete Minetest's API functions in Eclipse. As I'm a big fan of Vim, I decided to make a Minetest API Completer plugin for Vim (my first vim plugin though). Here's the first version of it :)

The plugin uses pretty simple regexp heuristics to get information about API functions (function declaration + docs) from lua_api.txt, forms a list of them, which is used to propose completion. To open the completion list, you need to press Ctrl+X and then Ctrl+O (omni completion). Or you can use a plugin, that will open completion list as you type

Link to plugin's GitHub: https://github.com/DraggonFantasy/vim-minetest-api

Re: Lua API Completer for Vim

PostPosted: Sat Aug 06, 2016 17:33
by kaeza
Nice!

I don't use vim, but this may be useful in generating whatever you need to implement code completion. I used it to generate API definitions for ZeroBrane Studio.

Note that the `minetest.ldef` (the source file) may need some updates.

HTH

Re: Lua API Completer for Vim

PostPosted: Sat Aug 06, 2016 18:17
by DraggonFantasy
Thanks!

That's interesting project :)
I decided to use contents of lua_api.txt for generating completion, because it will be always up-to-date. And it has some notes about each function, that are also shown in Vim when you navigate through functions in complete-list

Of course, the resulting function list may not be full using this method (simply ` sign in wrong place and the function will be omitted), but I find it not a very big problem, because roughly 90% of functions should be retrieved correctly. Last 10% can be fixed in lua_api.txt manualy and they will work too :)

Re: Lua API Completer for Vim

PostPosted: Sun Aug 07, 2016 18:35
by DraggonFantasy
Hm. I thought about combining lua_api.txt parsing and LDef. Like getting documentation notes from lua_api.txt and info about types from LDef. And it also will be cool because if there isn't some function in LDef, but it is in lua_api.txt - info about it will still be loaded.