Visual Studio Code extension for Leadwerks

I have been using Visual Studio Code for a couple of years now and it is my defacto text editor next to Notepadd++. I mainly use it however to write Lua scripts. 



Leadwerks extension

Personally I would love to see it if Visual Studio Code would be the default code editor for Leadwerks (either with 4.x or 5.x). So I got started on working on a custom Leadwerks extension.  You can download it here: https://marketplace.visualstudio.com/items?itemName=aggror.Leadwerks

Todo list:

  • Done: Leadwerks extension has a dependency on the Lua extension. So this Lua extension is automatically installed when you install the Leadwerks extension.
  • Done: Snippets. Every time you create a new script in the Leadwerks editor, you get a couple of default scripts like Function Script:Start(), UpdateWorld(), PostRender(context). Using a very simple snippet, these kind of functions can be inserted with ease.
    • prop[type] : Creates Leadwerk editor properties
    • print: Shortcut for System:Print("")
    • lescripts: Inserts all entity script functions (commented)
    • class: Creates a basic class objects with example functions
    • start: Start function of an entity script
    • updateworld: UpdateWorld function of an entity script
    • updatephysics: UpdatesPhysics function of an entity script
    • collision: Collision function of an entity script with all parameters
    • PostRender: PostRender function of an entity script with the context parameter
    • function: Creates a function for either a custom object or for the specific script
    • if
    • for
    • pair
    • ipar
  • For instance: just type 'col' followed by 1 tab and you get: 
  • function Script:Collision(entity0,entity1,position,normal,speed)
    
    end


  • Partially done: Supporting intellisense (sort of) with Leadwerks entities.
    • Lua is a typeless language (not a strong typed language), which makes intellisense not really possible. 
    • VS code is smart enough to recognise some functions that are available in your script, but it is not as complete as when you would work with C# or C++.
    • Done: Generate snippets for the entire Leadwerks API. 
      • Snippets are created per object and a second one without the object. For instance
        • Entity:SetPosition()
        • SetPosition()
      • TODO: Classes with parents, would require matching functions. For instance: a pivot is an entity and thus requires Pivot:SetPosition()
    • Done: parameters into placeholder slots.
    • If I can extend the intellisense so that it recognises Leadwerks entities, perhaps we could see correct variables and functions of those entities.
  • TODO: Loading in the API documentation in a split screen. 
    • The API documentation is written in an XML format which I can retrieve in VS code. I can display it in a splitscreen. 
    • I would have to play with the styling a bit but in general this should work really fast
    • API documentation can be cached if in online mode. Documentation could also be periodically fetched. Moving the API documentation to Github would help improve this process. (newer file versions etc)
  • Debugging
    • Josh stated that he is getting someone to make this for him. So fingers crossed. :)
    • The biggest issue at the moment is the lack of debugging support. Visual studio has debugging options of course, but it can't communicate with the Leadwerks editor.
    • If you have an error in your script while running from the editor, the default Lua editor is opened. :(