Coder Social home page Coder Social logo

coronasdk-sublimetext's Introduction

Solar2D Editor

Solar2D Editor (rebranded Corona Editor) is the official Solar2D plugin for Sublime Text. Designed to make building apps even easier by adding functionality to Sublime Text to improve developer productivity.

Sublime Text Version

Sublime Text 3 is required to use Solar2D Editor.

Installation Instructions

  1. Install the Sublime Text Package Control plugin if you don't already have it using Tools > Command Palette... > Install Package Control
  2. When that's installed, in Sublime Text choose: Tools > Command Palette... > Package Control: Install Package
  3. Find Corona Editor by typing in the search field, click on it to install it
  4. Restart Sublime Text to see the new features

If you want to help test the latest development version of Solar2D Editor you can configure Package Control to grab it instead of the official release version by following these steps:

  1. In Sublime Text choose: Tools > Command Palette... > Package Control: Remove Package and uninstall any installed version of Corona Editor
  2. Choose: Tools > Command Palette... > Package Control: Add Repository
  3. Enter https://github.com/coronalabs/CoronaSDK-SublimeText
  4. Choose: Tools > Command Palette... > Package Control: Install Package
  5. Find CoronaSDK-SublimeText (or, on some machines, Corona Editor - Daily Build) by typing in the search field, click on it to install it
  6. Restart Sublime Text or reopen any .lua files to see the new features

Alternatively, if you are comfortable doing manual installs of Sublime Text plugins and want to run the latest development version, you can download the plugin from https://github.com/coronalabs/CoronaSDK-SublimeText/archive/master.zip

If you install the tip from Github please report any issues using the Issues page on Github: https://github.com/coronalabs/CoronaSDK-SublimeText/issues

Using the Plugin

After restarting Sublime Text you'll have several new features available in the Solar2D Editor menu and in the context menu when editing Solar2D .lua files. Most of the features of the plugin rely on the current Syntax setting so when editing files you should use View > Syntax > Lua (Solar2D) command to set the correct syntax for the file. You will probably also want to change Sublime Text's default for .lua files by choosing View > Syntax > Open all with current extension as... > Lua (Solar2D) when you have a .lua file open in the editor.

If the syntax option is set correctly you'll see it displayed in the bottom righthand corner of the Sublime Text window.

There are several Sublime Text User Preferences that can be set to fine tune the behavior of the plugin. You can find information on setting User Preferences here http://www.sublimetext.com/docs/3/settings.html.

Debugger

Debugger allows code to be single stepped, variables to be examined and breakpoints to be set. You can run the debugger using the Solar2D Editor menu from any file in the project and it will automatically find main.lua. Right click on a code line in the editor and choose Toggle Breakpoint to turn a breakpoint on or off. Select the name of a variable and choose Inspect Variable from the context menu to see its value.

The following keys also control the Debugger:

Key Action
F10 Run Project in the Debugger or continue project execution
Shift+F10 Stop debugger
Super+F10 Run Project
F11 Step over
Shift+F11 Step into

A simpler alternative to the Build command in Sublime Text is the Run Project command in the Solar2D Editor menu (or Super+F10). It doesn't have all the bells and whistles of the build system but it is quick and easy. It is also better at finding your project's main.lua if you aren't using Sublime Text's projects. Super+B (usually bound to the Build command) is now bound to the Run Project command for Solar2D Lua files.

On macOS, if you install Solar2D in /Applications without changing the default name, it will use the highest numbered (most recent) build to run the project (to change this behavior, see corona_sdk_simulator_path below).

Preferences
  • corona_sdk_simulator_path (default: system dependent)

    Set this to the path of your Solar2D Simulator if it's not installed in the default location for your operating system (remember to double the backslashes in Windows paths). You can also set this in the build.settings file of individual projects to customize the version of the Solar2D Simulator that is used for each project (note that the Lua syntax for the build.settings file is different to the JSON syntax of the Sublime Text preference files in that the name of the preference is not quoted in Lua).

  • corona_sdk_simulator_show_console (default: false)

    Set this to true to have the Solar2D Simulator Console be shown when running a project with Super+F10 (or Super+B).

Current Gotchas
  • If you Run the project and it doesn't hit a breakpoint, you'll have to stop and restart to regain control (in particular, setting a breakpoint on a line of code you know is being executed wont stop the program).
  • Single stepping through "internal locations" is tedious.
  • There's an implicit breakpoint set on the first line of main.lua so to hit your own first breakpoint you need to run once to start the debugger and stop on the first line then run again to continue until you hit your own breakpoint.
  • If you create rows and columns in using Sublime Text's View > Layout command in the current tab, the debugger wont create its own panes and its functionality will be reduced.

Completion

Completion works for all API calls and constants (correctly handling periods in the name). Fuzzy matching is optionally done to increase the chances of finding the item you are looking for. Completion relies on the current Syntax setting so when creating new files you should use View > Syntax > Lua (Solar2D) command to set the correct syntax for the new file. You will probably also want to change Sublime Text's default for .lua files by choosing View > Syntax > Open all with current extension as... > Lua (Solar2D) when you have a .lua file open in the editor.

Preferences
  • corona_sdk_completion (default: True)

    If you don't like Solar2D Editor's completion you can turn it off entirely using this preference.

  • corona_sdk_use_fuzzy_completion (default: True)

    Turn off "fuzzy completion" and just complete based on the characters typed so far as a prefix.

  • corona_sdk_complete_periods (default: True)

    Solar2D Editor turns off the special meaning of periods as "word separators" in Sublime Text to make Solar2D completions work better. If you like to use cursor movement keys like "Alt+Arrow" to move to the periods in function calls you might want to turn this off. The most obvious effect of turning it off is that when you type a period all the completions disappear until you type another character.

  • corona_sdk_use_docset (default: public)

    Choose which completion set you want to use. Can be one of public (the default), legacy(deprecated) or daily(deprecated).

  • corona_completions_strip_white_space (default: False)

    Set to true if you want items to be completed with minimal whitespace included.

Current Gotchas
  • The order of items in the completions popup seems a little odd but is due to Sublime Text's "fuzzy" matching

  • Some of the completions may have minor errors with nested optional parameters due to the way they are automatically generated.

Documentation Lookup

Documentation can be called up by placing the cursor on an API call (or selecting it) and either hitting F1 or choosing Solar2D Docs from the context menu. Lua keywords will be looked up in the Lua documentation. If the context of something isn't recognized, a search of the Solar2D documentation will be initiated.

Current Gotchas
  • Note that right clicking on an item wont move the cursor there so you can't right click on a term that's not at the insertion point and then pick Solar2D Docs from the context menu as it's the position of the text cursor that determines what's looked up (left click on the item first)

Snippets

A selection of commonly used code fragments and templates is available via the Solar2D Editor > Snippets menu. Selecting an item from a submenu will insert its code at the current insertion point in the file.

A default set of snippets is created in the Sublime Text support folder Packages/User/Corona Editor/Snippets. You can create your own folders and files to add to the default set. Files should either be Sublime Text .sublime-snippet files or plain text files. The contents of plain text files are just inserted when chosen unless they exactly match a completion entry in which case the completion is looked up and they work like a normal completion (you can tab between the arguments) which provides a way to make menus of hard to remember API calls.

Build System

The Run Project command in the Solar2D Editor menu (or Super+B or Super+F10) is a simpler alternative to the Build command in Sublime Text (see above for more information).

Syntax Highlighting

Syntax highlighting of Lua with Solar2D calls is done (choose View > Syntax > Lua (Solar2D) to enable this). You will probably also want to change Sublime Text's default for .lua files by choosing View > Syntax > Open all with current extension as... > Lua (Solar2D) when you have a .lua file open in the editor.

Miscellaneous

  • A shortcut to the Sublime Text Goto Anything... function list has been added to the context menu as Function Navigator.... This lists the functions defined in the current file and choosing one takes you to that definition.
  • The Solar2D Editor menu has a Show/Hide Build Panel command to toggle the visibility of the Build Results panel (which displays the output of the Simulator). Note that hiding the panel clears its contents.

Reporting Issues

You can find discussion about Solar2D Editor on the forums.

If some aspect of the plugin doesn't behave as expected be sure to include any console output when reporting the problem. You can view the console using View > Show Console and copy and paste the information displayed there.

Known Issues

  • Syntax highlighting is incorrect for function definitions that look like:
local back=simplebutton.create("Back",function() menumanager.openMenu("main") end)

Platform Specific Advice

Mac

You may want to set the Use all F1, F2, etc. keys as standard function keys option in System Preferences > Keyboard to make using F10 and F11 easier for the debugger. Alternatively you may want to reassign the keys used to drive the debugger; information on how to this can be found at http://www.sublimetext.com/docs/key-bindings

Thanks

Many thanks to the Solar2D users who have provided feedback and suggestions to make Solar2D Editor even better. Particular thanks to personalnadir, develephant, givemeyourgits and landoncope for their contributions and help.

coronasdk-sublimetext's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

coronasdk-sublimetext's Issues

Incorrect Syntax Highlights on local functions

Lines like

local anim=function(time)

Aren't correctly highlighted in version 1.0 of Corona Editor. The local keyword and the variable the function is stored in are highlighted, as is the time parameter, but the function keyword is not.

If the line is changed to

anim=function(time)

The highlighting switched and the function keyword is recognised as a language keyword

FYI: The new Corona rebranding breaks this plugin

It's a minor inconvenience that could be addressed with an addition to the docs really.

Basically the new rebranding now installs (in OSX) as Corona-<version> so you need to rename your install dir as CoronaSDK in order for the editor to work.

It would be awesome if the editor would have a preference that would allow you to launch a specific version of the SDK. I always keep many versions installed for testing but can only debug with the one that's named CoronaSDK.

Optional function arguments enhancement

For example, this is what happens when using auto completion for display.newImage()
screen shot 2016-08-03 at 02 40 48

I think it would make much more sense to also mark the trailing comma like this:
screen shot 2016-08-03 at 02 42 53

That would make deleting an argument much quicker. Maybe that's my personal opinion but just wanted to bring it up anyways in case anyone else agrees.

I could make a pull request in case that is in fact the desired behavior.

“syntax” setting is forcibly changed to “Corona Lua”.

I save my work, goes back to "Lua" to "Corona Lua".
p.s: Please remember that some users like me use the syntax set to "Lua". (NOT CORONA LUA)

[Plugin Version Info]
Corona Editor for Sublime Text
Version: 2020.08.02.06.33.56
Installed: 2020-08-25 17:59:08.490094
Corona Editor is the official Corona SDK plugin for Sublime Text
[Sublime Text 3211/stable/osx/x64]

[Package Control Settings Info]
{
"bootstrapped": true,
"in_process_packages":
[
],
"installed_packages":
[
"CoronaSDK-SublimeText",
"Package Control"
],
"repositories":
[
"https://github.com/coronalabs/CoronaSDK-SublimeText",
]
}

Simulator not opening right

Thank you for working on this!
Unfortunately the simulator does not open right. When I hit "Run Project" in sublime, the simulator starts opening (showing up in dock (on macOS)), but the simulator windows itself is not showing up. I've tried to open the simulator normally, working fine. Only when I open the project through this sublime plugin, it doesn't show up.

I have the latest solar2d build and latest corona editor that you've updated few hours ago.

Would be very grateful if this bug could be fixed.
Thanks

corona_sdk_complete_periods only modifies word separators one way

I noticed that in completions.py:214 the code modifies the word separators for the current view. However the code only functions one way. If the user modifies 'corona_sdk_complete_periods' to be False after it has been executed the code won't restore the original value of the word separators.

Go To Symbol not working correctly

The Go To Symbol (CMD+R) shortcut is not properly working anymore when you define a function as following:

local getHello = function()
end

The Symbol appearing on the list is "function" instead of "getHello"

Previously written text disappears with code completion

When "corona_sdk_complete_periods": true is set, previously written text can sometimes disappear. Try writing:

display.co

Choose display.contentCenterX from the code completion dropdown. "display." will disappear.

The same thing happens for many other entries like display.HiddenStatusBar etc.
Setting "corona_sdk_complete_periods": false fixes the issue.

No preference settings when using dev branch

OSX

When installing the development branch from Package Control no preference settings are available under Preferences->Package Settings->Corona Editor. I can see all the menu options (README, Release notes etc.) but they all open up a blank page.

Make sure all old Corona Editor settings are gone before installing the dev branch. (.../Library/Application Support/Sublime Text 3)

Corona SDK Debugger not working anymore (latest dev. build)

Using the latest Corona 2020.3583 build with SublimeText build 3211, the debugger does not work anymore and all the options (Run, Toggle Breakpoints etc.) in the dropdown are just greyed-out.

I've tested this with another earlier daily build and the same issues persisted - however with the latest build, using the normal Corona Editor, the Corona Editor tab doesn't even appear anymore. So I've tried switching from that to the latest one over at https://github.com/coronalabs/CoronaSDK-SublimeText but the debugger still only has greyed-out options.

Launching the application normally through SublimeText 3 works, however.

Plugin only works on install, crash if sublime is relaunched

When I install the plugin, everything works fine.
If sublime is relaunched, completions doesn't work anymore, and probably other stuffs. This is what the console says:

reloading plugin Corona Editor._corona_utils
reloading plugin Corona Editor._lua_paths
reloading plugin Corona Editor._sublime_utils
reloading plugin Corona Editor.about
reloading plugin Corona Editor.completions
Traceback (most recent call last):
  File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 116, in reload_plugin
    m = importlib.import_module(modulename)
  File "./python3.3/importlib/__init__.py", line 90, in import_module
  File "<frozen importlib._bootstrap>", line 1584, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1565, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1532, in _find_and_load_unlocked
  File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 1183, in load_module
    exec(compile(source, source_path, 'exec'), mod.__dict__)
  File "/Users/akabab/Library/Application Support/Sublime Text 3/Installed Packages/Corona Editor.sublime-package/completions.py", line 27, in <module>
FileNotFoundError: [Errno 2] No such file or directory: 'User/CoronaSDKLua.sublime-settings'
reloading plugin Corona Editor.corona_docs
reloading plugin Corona Editor.debugger
Traceback (most recent call last):
  File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 116, in reload_plugin
    m = importlib.import_module(modulename)
  File "./python3.3/importlib/__init__.py", line 90, in import_module
  File "<frozen importlib._bootstrap>", line 1584, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1565, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1532, in _find_and_load_unlocked
  File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 1183, in load_module
    exec(compile(source, source_path, 'exec'), mod.__dict__)
  File "/Users/akabab/Library/Application Support/Sublime Text 3/Installed Packages/Corona Editor.sublime-package/debugger.py", line 20, in <module>
FileNotFoundError: [Errno 2] No such file or directory: 'User/CoronaSDKLua.sublime-settings'
reloading plugin Corona Editor.run_project
reloading plugin Corona Editor.snippets
Traceback (most recent call last):
  File "/Users/akabab/Library/Application Support/Sublime Text 3/Installed Packages/Corona Editor.sublime-package/snippets.py", line 19, in <module>
  File "<frozen importlib._bootstrap>", line 1565, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1532, in _find_and_load_unlocked
  File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 1183, in load_module
    exec(compile(source, source_path, 'exec'), mod.__dict__)
  File "/Users/akabab/Library/Application Support/Sublime Text 3/Installed Packages/Corona Editor.sublime-package/completions.py", line 27, in <module>
FileNotFoundError: [Errno 2] No such file or directory: 'User/CoronaSDKLua.sublime-settings'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 116, in reload_plugin
    m = importlib.import_module(modulename)
  File "./python3.3/importlib/__init__.py", line 90, in import_module
  File "<frozen importlib._bootstrap>", line 1584, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1565, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1532, in _find_and_load_unlocked
  File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 1183, in load_module
    exec(compile(source, source_path, 'exec'), mod.__dict__)
  File "/Users/akabab/Library/Application Support/Sublime Text 3/Installed Packages/Corona Editor.sublime-package/snippets.py", line 21, in <module>
ImportError: No module named 'completions'

Any idea?
Thx u

Corona file paths embedded into code

When the Corona package changes to Solar all the paths in _corona_utils.py will need to be updated. They should be extracted into constants to make the change smoother (and support those who do not make the switch).

Fields set from settings in _init_ are set to None

I don't know why, but when Sublime starts up, the settings set in the init function are set to None (it even ignores the default values). Afterwards, when Sublime reloads the file, the values are set correctly using either the default value or the values taken from Corona Editor.sublime-settings

Error loading syntax file

v1.7.6, gives me the error

Error loading syntax file "Packages/CoronaSDK-SublimeText/CoronaSDKLua.sublime-syntax": Unable to read Packages/CoronaSDK-SublimeText/CoronaSDKLua.sublime-syntax

As a result, syntax highlighting doesn't work.
Using latest Sublime v3.2.2, build 3211 on Windows.

Autocomplete ignores text before period

The support for Corona's API is great, but one bugbear of mine is that typing

timer.pe

and hitting tab to select the autocomplete suggestion results in

timer.timer.performWithDelay( delay, listener [, iterations] )

While it's not major, I do occasionally miss that that has happened. I'm using ST3 3059 with the following set in my settings file:

    "auto_complete_commit_on_tab": true,
    "auto_complete_with_fields": true,

Save Console Output

A user asks:
Is there a way to preserve the Build Results output in the console window? There's often useful bits of info in there which I find handy for debugging, but as soon as you click in it, poof the content disappears and there doesn't seem to be a way to get it back other than re-building...

GoTo Symbol not getting functions defined inside tables (Sublime 3)

I have been using Corona Editor on Sublime 2 for a while without problem. I just moved to Sublime 3 and I noticed that the Goto Symbo (CMD+R) is not listing functions defined inside a tablet (e.g: server.login = function() ... end). On Sublime 2 it was working fine.

Run Project stopped working

I am not able to call "Corona Editor - >Run Project" anymore (or CMD+B) (OS X)

I keep getting an error popup with the message:
The document "main.lua" could not be opened. Corona Simulator cannot open files in the "Lua Source Code" format.

Is it only me?

No Corona Editor Menu in Sublime 2

I just upgraded to the most recent version via Package Control, and the Corona Editor menu is gone. Here's the console error:

snippets exception: [Errno 2] No such file or directory: 'Packages/Corona Editor/Main.sublime-menu.template'
Corona Editor: Failed to load Snippets menu: Packages/Corona Editor/Main.sublime-menu.template

I have verified that the file is indeed at that location within the Sublime 2 installation directory.

Simulator of newest Solar2d build is not opening right on "run project"

With the newest Solar2d build (2020.3598) opening the simulator through sublime text 3 doesn't work on MacOs.

The icon appears in the dock, but the simulator itself does not open.
screenshot

I tried to enter the path to the simulator manually in the Corona Editor.sublime-settings file, but that didn't help. Setting the path to another old Corona build (2018.3326) does work well. So the path seems not to be the reason for this issue.

I can open the simulator manually though, but not through sublime.

Maybe you guys can take a look into it some time. Appreciate it.
Thanks

Corona Editor may be writing to global setttings

Apologies, this might be me getting it wrong, but Completions.py checks settings by looking at what's returned from view.settings(). However I think that that function only provides access to Sublime's settings rather than Corona Editor's.

You can check this by opening a file, setting the syntax to Corona SDK Lua and then opening in console.

Check that the console's view matches the file opened by typing view.file_name() into the console. If you then enter view.settings().get("tab_size") you'll see that the Sublime Text tab size setting is returned correctly. However if you type view.settings().has("corona_sdk_auto_build") you'll see that it returns False.

I think that to correctly check Corona Editors settings you need to do the following:

settings = sublime.load_settings('Corona Editor.sublime-settings')
settings.get("corona_sdk_complete_periods")

I believe this issue is causing Corona Editor to edit the word_syntax field globally, as opposed to locally as intended

Bracket auto match in Lua comment line

If I try to add a Lua block comment using "--[[", Sublime wants to make it "--[[]]". Sublime should ignore auto completions after the start of a comment "--".

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.