Page 1 of 1

Factorio API autocomplete extension for Visual Studio Code

Posted: Sun Apr 30, 2017 7:24 pm
by ibeatbabybiters
Hello,

I've recently bought the game and wanted to start modding, but first I wanted to make life easier by having the official API documentation inside my editor. And so I've created a VS Code extension that provides autocompletion for the Factorio API.

Features:
  • Autocomplete of all Lua classes and globals
Image
Image
  • Mouse hover tooltips
It can be installed directly in VS Code by searching for "factorio" in the extension gallery.
Marketplace: https://marketplace.visualstudio.com/it ... tocomplete
Github: https://github.com/simonvizzini/vscode- ... tocomplete

VS Code is free and open source, by the way!

Feedback welcome! The extension still requires some polishing so there may be some quirks here and there. Especially the formatting of the documentation is a bit wonky, because converting HTML to plain text is a bit difficult and I don't think I'll be able to improve it much more. Best solution would be to have the API documentation available in another format than HTML, but the dev's would need to provide that (I'm not sure how they generate their API docs). At least it was quite fun to try this web scraping stuff for once.

If you want to contribute then feel free to create a pull request, report bugs or just make a suggestion :)

Happy modding!

Re: Factorio API autocomplete extension for Visual Studio Code

Posted: Sun Apr 30, 2017 11:23 pm
by steinio
Nice, i will try it out.

Greetings, steinio.

Re: Factorio API autocomplete extension for Visual Studio Code

Posted: Thu May 04, 2017 9:25 pm
by ibeatbabybiters
Heya,

I've released a new version with some new features and improvements! See first post, I'll keep it updated in the future.

Re: Factorio API autocomplete extension for Visual Studio Code

Posted: Fri May 05, 2017 4:59 am
by steinio
ibeatbabybiters wrote:Heya,

I've released a new version with some new features and improvements! See first post, I'll keep it updated in the future.
Hi,

funny that VS C notified me already about an update.
The whole app seems a bit wonky but that's not your fault.

I believe the new settings api is not implemented now?
Greetings, steinio.

Re: Factorio API autocomplete extension for Visual Studio Code

Posted: Fri May 05, 2017 5:10 am
by AndrewIRL
Impressive

Re: Factorio API autocomplete extension for Visual Studio Code

Posted: Fri May 05, 2017 8:37 am
by ibeatbabybiters
@steinio: The new settings API should be there, though it's currently not offering autocomplete for the global "setting" word, instead you'd have to type "LuaSetting" for now to get autocomplete. I'll add it as a global in the next update. Also documentation (http://lua-api.factorio.com/latest/LuaSettings.html) is currently missing and seems to be only available in the stickied feedpack post for now. Once it's in the API docs it will be also available in the extension.

What I'd like to also implement is some kind of setting so users can define their own global triggers, for example if you have functions like:

Code: Select all

function doSomethingWithTrain(myTrain) -- myTrain is of type LuaTrain
    myTrain....
end
you'd get no autocomplete for "myTrain" because there is no way to know what type "myTrain" actually is. So eventually it will be possible to add a custom trigger which would then give suggestions for "LuaTrain" if it detects the "myTrain" word. This would be mainly useful if you have multiple functions that take certain types with fixed names. It's not a perfect solution but at least better than nothing.

@AndrewIRL: Thanks! =)

Re: Factorio API autocomplete extension for Visual Studio Code

Posted: Mon May 08, 2017 8:44 am
by Dustine
Thank you!! Nexela pointed me to this post and this does about exactly what I've been wanting all along (specially if you count your wishlist features :D)

Re: Factorio API autocomplete extension for Visual Studio Code

Posted: Mon May 29, 2017 10:09 pm
by ibeatbabybiters
Just wanted to say I haven't stopped working on this, I just got so much other stuff to do lately, like finally playing the 0.15 update :D I've made some improvements which I need to finish, like converting the docs into markdown with clickable links to the official docs etc, but it's far from perfect. Parsing the HTMl is kinda messy and no fun. i think I'm doing it wrong =/

Re: Factorio API autocomplete extension for Visual Studio Code

Posted: Sun Jun 04, 2017 4:53 pm
by ibeatbabybiters
I spent another evening trying to parse that stupid HTML and it's still a mess but I'm happy with the result. Tooltips are now fully markdown formatted, with links to the official api docs. It's not perfect but I'm not gonna touch that anytime soon again.

Also class inheritance is now considered, so for example properties of type LuaEntity will now also offer suggestions from its parent class LuaControl. Also I managed to scrape all the LuaControlBehavior types.

I think, now I'm ready to write my first mod :D

Happy modding and let me know if you experience any issues.

Re: Factorio API autocomplete extension for Visual Studio Code

Posted: Thu Feb 01, 2018 12:31 pm
by unobtanium
Hey, any chance of updating this to the newest version of Factorio?
Or maybe providing some sort of guide on how to generate a new version from the API documentation myself and others? That would be great! :)

Re: Factorio API autocomplete extension for Visual Studio Code

Posted: Sun Feb 18, 2018 3:31 pm
by darkfrei
Is it possible to make it as Notepad++ plugin?

Re: Factorio API autocomplete extension for Visual Studio Code

Posted: Sat Jun 01, 2019 7:21 pm
by Roang
I've updated the extension with the latest data, the version is available as download at: https://github.com/Roang-zero1/vscode-f ... /releases/

I've also updated the Readme of the extension to show how to update the data on your own.