Typehints and documentation in vscode
Posted: 09 Jan 2022, 21:11
If you've done any lua programming, you will probably have run into the annoyance of having to check the luadocs every time you writte a function to see if you've written it correctly.
In order to improve the experience i made a script for turning the luadocs into EmmyLua notations.
Advantages
By using the annotations you will have
Because of the way the lua plugin works, the theodocs.lua file must be kept open for the docs to show up.
Since im too lazy to manually document every type of gui object all their functions are listed under the same GUI type, meaning it will show functions like getLastPart on gui objects that are not layouts.
Installation
In order to improve the experience i made a script for turning the luadocs into EmmyLua notations.
Advantages
By using the annotations you will have
- Autofill when typing
- Type hints on return values
- Documentation when hovering over api functions, including information about parameter and return types
Because of the way the lua plugin works, the theodocs.lua file must be kept open for the docs to show up.
Since im too lazy to manually document every type of gui object all their functions are listed under the same GUI type, meaning it will show functions like getLastPart on gui objects that are not layouts.
Installation
- To use the annotations you will need to install vscode first, download vscode
- Install the Lua Language Server coded by Lua
- Open your desired workspace, i use the theotown folder (just make sure you dont accidentally publish it with your plugin).
- In the top level of your folder, create a folder named ".vscode", if it already exists you dont need to change anything
- Put the contents of this zip into the folder
- Enjoy a more comfortable coding experience