Lua API Completer for Vim

DraggonFantasy
New member
 
Posts: 7
Joined: Tue Aug 02, 2016 12:51
GitHub: DraggonFantasy
IRC: DraggonFantasy
In-game: DraggonFantasy

Lua API Completer for Vim

by DraggonFantasy » Fri Aug 05, 2016 19:05

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
 

User avatar
kaeza
Member
 
Posts: 2141
Joined: Thu Oct 18, 2012 05:00
GitHub: kaeza
IRC: kaeza diemartin blaaaaargh
In-game: kaeza

Re: Lua API Completer for Vim

by kaeza » Sat Aug 06, 2016 17:33

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
Your signature is not the place for a blog post. Please keep it as concise as possible. Thank you!

Check out my stuff! | Donations greatly appreciated! PayPal | BTC: 1DFZAa5VtNG7Levux4oP6BuUzr1e83pJK2
 

DraggonFantasy
New member
 
Posts: 7
Joined: Tue Aug 02, 2016 12:51
GitHub: DraggonFantasy
IRC: DraggonFantasy
In-game: DraggonFantasy

Re: Lua API Completer for Vim

by DraggonFantasy » Sat Aug 06, 2016 18:17

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 :)
 

DraggonFantasy
New member
 
Posts: 7
Joined: Tue Aug 02, 2016 12:51
GitHub: DraggonFantasy
IRC: DraggonFantasy
In-game: DraggonFantasy

Re: Lua API Completer for Vim

by DraggonFantasy » Sun Aug 07, 2016 18:35

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.
 


Return to Minetest-Related

Who is online

Users browsing this forum: No registered users and 26 guests

cron