Typehints and documentation in vscode

The Lua scripting language allows you to give your plugin more advanced features.

Moderator: Plugin Moderators

User avatar
erksmit
Villager
Reactions:
Posts: 23
Joined: 02 Mar 2018, 12:39
Plugins: Showcase Store
Version: Beta

Plugin Creator

Typehints and documentation in vscode

#1

Post by erksmit »

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
  • Autofill when typing
    autofill.png
  • Type hints on return values
    returnType.png
    returnType.png (8.91 KiB) Viewed 3077 times
  • Documentation when hovering over api functions, including information about parameter and return types
    documentation (2).png
Limitations
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
  1. To use the annotations you will need to install vscode first, download vscode
  2. Install the Lua Language Server coded by Lua
    Install In VSCode.gif
    Install In VSCode.gif (76.4 KiB) Viewed 3077 times
  3. Open your desired workspace, i use the theotown folder (just make sure you dont accidentally publish it with your plugin).
  4. In the top level of your folder, create a folder named ".vscode", if it already exists you dont need to change anything
  5. Put the contents of this zip into the folder
    .vscode.zip
    (26.38 KiB) Downloaded 78 times
  6. Enjoy a more comfortable coding experience
I will be updating these docs when i improve my parsing script or when new functions are added
Naamloos.png
Naamloos.png (7.42 KiB) Viewed 3058 times
User avatar
Simon142
Small-town resident
Reactions:
Posts: 35
Joined: 05 Feb 2020, 14:13
Plugins: Showcase Store

Plugin Creator

Platform

Re: Typehints and documentation in vscode

#2

Post by Simon142 »

Epic (amazing) (I love this)
User avatar
The26
Inhabitant of a Megacity
Reactions:
Posts: 181
Joined: 23 May 2018, 22:18
Location: Lithuania
Plugins: Showcase Store
Version: Beta

Plugin Creator

Platform

Re: Typehints and documentation in vscode

#3

Post by The26 »

This is epic (real) (epic) (real epic) (epic (real))
Post Reply Previous topicNext topic

Return to “Lua Scripting”