evaera / RbxSync

[ARCHIVED] Third party IDE support for Roblox Studio.
GNU General Public License v3.0
31 stars 12 forks source link

Add Custom Languages #27

Closed TBSHRichard closed 6 years ago

TBSHRichard commented 6 years ago

Overview

New Feature

Custom Language Format

New languages can be added to the language path (set by the user, defaults to ~/Documents/ROBLOX/RbxSyncLanguages). The app looks in each folder in this path (non-recursive) for a lang.js file. This file should export an object with the following format:

module.exports = {
  info: {
    // (required, string) The file extension of the language
    extension: ...,
    // (required, string) The syntax of the language; used to communicate between ROBLOX and RbxSync the language to use
    syntax: ...,
    // (default = false, boolean) Whether or not to send the language info to the ROBLOX Studio plugin
    sendToRobloxStudio: false,
    // (required if sendToRobloxStudio is true, string) The name of the StringValue object that's created in ROBLOX to store the original source
    originalSourceValueName: ...,
    // The default source text that will be placed in a newly created script
    defaultSource: ...,
    // (default = [], array[string]) ROBLOX ClassNames that the language CANNOT be created from (Script, LocalScript, ModuleScript)
      // If the ROBLOX script Class is not allowed by a language, Lua will be used instead
    unallowedRobloxClasses: [...],
    // (default = [], array[object]) Shortcuts that can be used to initialize a language script, other than creating the StringValue child
    initializationShortcuts: [{
      // (required, string) The type of shortcut:
        // 'source' - The language can be initialized if the source of the new script (lowercased) matches the value
        // 'extension' - Looks for the value at the end of the script name
        // 'hotkey' - The last entry in the key code enum (i.e. Enum.KeyCode.<value>); initialized with Ctrl+Alt+Hotkey
          // I could not get the hotkey shortcut for MoonScript working before I made changes, as such this is not working either
          // Did a ROBLOX Studio update break this?
      type: ...,
      // (required, string) The value to initialize with
      value: ...
    }],
    // (default = [], array[object]) Extra ModuleScripts that the language depends upon; RbxSync inserts these ModuleScripts if the don't exist
    luaIncludes: [{
      // (required, string) The path of the file, relative to the language folder, that contains the source of the ModuleScript
      file: ...,
      // (required, string) The name of the ModuleScript
      name: ...,
      // (default = null, string) The version number of the ModuleScript; this will create a versioned-folder to allow multiple versions of the ModuleScript
      version: ...,
      // (required, string) The ROBLOX destination to place the ModuleScript, relative to game; e.g. 'ServerScriptService.src'
      destination: ...
    }]
  },
  transpile: function(file, fileSource, addCommand, guid) {
    // file       is the path to the physical file
    // fileSource is the contents of the file
    // addCommand is the addCommand function from the server
    // guid       is the script's GUID
  }
};
evaera commented 6 years ago

I almost feel kind of bad that you did all this work on the version 1 code base, since CoffeeScript is kinda gross to me now :P This looks pretty cool, though. I appreciate all the work you did for this on my project! I'll check out the changes now.

TBSHRichard commented 6 years ago

Haha, it's no problem. This is a feature I've wanted so I wouldn't have to manually transpile my code anymore so I've just made changes to what exists right now. :)

evaera commented 6 years ago

Issues found:

TBSHRichard commented 6 years ago

Okay, I'll look into these and fix them as soon as possible.

TBSHRichard commented 6 years ago

I was able to fix most of the issues.

As for the keyboard shortcuts, it seems like they are only working when the game has focus. When most other panels in Studio get focus (such as the Explorer) it seems like the keyboard events stop happening. I have tried the shortcuts with all my changes removed and the same behavior is present.

Do you have something extra installed that allows the shortcuts to work before my changes?

evaera commented 6 years ago

No, shortcuts have always only worked when the window 3d view is focused sadly. Although, now that you mention it, this could easily be added into RbxSync itself...but I think we will save that for another time or another PR at least. :)

I will test out these changes soon and and get back to you. I am excited to push this out in a release :)

TBSHRichard commented 6 years ago

I was not clear enough, sorry.

I was referring to shortcuts all within Studio. If you click on the game panel and press Ctrl+Alt+B the message pops up saying to select Scripts. But if you click on the Explorer panel to select Scripts and press the shortcut, nothing happens.

This scenario happens for me before and after the changes I've made.

evaera commented 6 years ago

Yes, that's what I was referring to as well

TBSHRichard commented 6 years ago

Ah, okay. Well in that case, the MoonScript shortcut should be working as it was before! :)

evaera commented 6 years ago

And just like that it's been months and I still haven't implemented this. 🤦‍♂️

Haven't forgotten. Coming soon ™️