ctrl+shift+p filters: :st2 :st3 :win :osx :linux
Browse

Electric Imp Developer

by electricimp ST3

Sublime Text 3 plug-in for Electric Imp applications development

Details

Installs

  • Total 18
  • Win 10
  • OS X 6
  • Linux 2
Jul 21 Jul 20 Jul 19 Jul 18 Jul 17 Jul 16 Jul 15 Jul 14 Jul 13 Jul 12 Jul 11 Jul 10 Jul 9 Jul 8 Jul 7 Jul 6 Jul 5 Jul 4 Jul 3 Jul 2 Jul 1 Jun 30 Jun 29 Jun 28 Jun 27 Jun 26 Jun 25 Jun 24 Jun 23 Jun 22 Jun 21 Jun 20 Jun 19 Jun 18 Jun 17 Jun 16 Jun 15 Jun 14 Jun 13 Jun 12 Jun 11 Jun 10 Jun 9 Jun 8 Jun 7
Windows 2 0 0 0 0 0 0 1 0 0 0 0 0 0 0 2 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0
OS X 0 4 1 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0
Linux 0 0 2 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

Readme

Source
raw.​githubusercontent.​com

Electric Imp Sublime Plug-in (Beta)

Sublime Text 3 plug-in for Electric Imp applications development.

Overview

The Plug-in is designed to improve developer productivity and allows to rapidly build and maintain applications by providing:

  • Code auto-completion for Electric Imp Squirrel API
  • Ability to use a source control system to manage application code and configuration
  • Advanced Squirrel code highlighting
  • Integration the Builder to enable multi-file projects and code preprocessing
  • Live logs with clickable stack traces for errors with navigation to the file and line in question
  • Using key shortcuts for frequent operations (build and run, show console, etc)
  • Leveraging the rich set of Sublime Text 3 Editor features.

The Plug-in requires connection to the Internet as it leverages the Electric Imp Build API to work with the the Electric Imp impCloud™.

Installation Steps

NOTE: Electric Imp Sublime Plug-in supports Sublime Text 3 only, no other versions are supported. Tested on macOS only.

Install Node.js

NOTE: The plug-in requires Node.js 4.0 or above.

Please follow these instructions to install Node on your machine.

Install the Builder Node.js Module

The plug-in uses the Builder Node.js module for source code pre-processing. To install Builder, please use Node Package Manage (NPM):

npm i -g Builder

Install the Electric Imp Sublime Plug-in

Package Control

If you already have Package Control installed in Sublime Text:

  • Select Install Package from the Command Palette: Ctrl+Shift+P on Windows and Linux or ⇧⌘P on macOS
  • Search for Electric Imp Developer and click enter.

From Sublime Text Terminal

You can install the plug-in script via the following command in the Sublime Text terminal (ctrl+`) which utilizes git clone.

NOTE: Please make sure you have git installed on your system when trying this method.

import os; path=sublime.packages_path(); ie_plugin_path=os.path.join(path, 'imp-developer'); (os.makedirs(path) if not os.path.exists(path) else None); window.run_command('exec', {'cmd': ['git', 'clone', 'https://github.com/electricimp/ElectricImp-Sublime.git', 'imp-developer'], 'working_dir': path}) if not os.path.exists(ie_plugin_path) else window.run_command('exec', {'cmd': ['git', 'pull'], 'working_dir': ie_plugin_path})

Manual

Alternatively, follow these steps to install the plug-in manually:

  1. Create the plug-in folder:

    • macOS: /Users/<username>/Library/Application Support/Sublime Text 3/Packages/imp-developer
    • Windows: “%AppData%\Sublime Text 3\Packages\imp-developer%”
  2. Do one of the following:

Usage

Creating a New Project

Your first step should be the creation of a new project. Do this by selecting the Tools > Packages > Electric Imp > Create Project menu item. You will then be asked to specify the project folder.

The project folder will be set up with the following

-- <Project Name>
  |--> settings                           - Electric Imp settings folder
  .   |--> auth.info                      - SENSITIVE: Build API key and GitHub authentication information
  .   |--> electric-imp.settings          - Generic Electric Imp settings
  |--> src                                - Source folder 
  .   |--> device.nut                     - Device code
  .   |--> agent.nut                      - Agent code
  |--> .gitignore                         - .gitignore file to exclude Build API key from git repository
  |--> electric-imp.sublime-project       - Sublime project file

IMPORTANT: settings/auth.info should not be put under a source control as it contains sensitive information!

The electric-imp.settings file contains:

  • Imp Model ID for the project
  • Selected device id
  • Device and Agent code file names
{
  "model-id"      : "my-model-id",
  "device-id"     : "my-selected-device-id",
  "device-file"   : "src/device.nut",
  "agent-file"    : "src/agent.nut",
}

When a project is created, empty device and agent code files (device.nut and agent.nut) are automatically created and stored in the <Project Name>/src folder.

If a project is created successfully, a new window with the project folder is opened.

NOTE: If you need to apply the Squirrel language syntax highlighting to files with extension other than .nut please make sure you have Squirrel (Electric Imp) language selected under the View > Syntax menu item.

Opening an Existing Project

To open an existing Electric Imp project, select the Project > Open Project... menu option and choose the <Project Name>.sublime-project file from your project folder.

NOTE: The plug-in won't properly detect Electric Imp project if it is not opened as described, ie. if it is opened as a folder, not as a Text Sublime project!

Building and Running

To build and deploy the application code, please select the Tools > Packages > Electric Imp > Build and Run menu item. This action uploads the agent and the device code to the server, and restarts all of the devices assigned to the model.

When you build code (or perform any other action that requires access to the impCloud™) for the first time, you will be asked to provide:

  • The path to the Node.js executable (if it is not automatically detected by the plug-in).
  • The location of the Builder cli.js command line tool (if not automatically detected by the plug-in).
  • Your Build API Key, which can be obtained at the Electric Imp IDE by clicking on the username > Build API Keys menu item at the top right of the screen.
  • A model name. A model with this name will be created for the project, or if the name matches an existing model, that will be used instead.

NOTE: To build and deploy your code it isn’t necessary to select a device for your project. Even if you don’t have a device selected, you can still work on the code and see compilation errors reported by the server.

If you want to have you code running on a specific device and view the logs from that device, you need to select a device using the Tools > Packages > Electric Imp > Add Device menu item.

Model Management

Each Electric Imp project is associated with a particular model, ie. the device and agent code that define your application. You can create a new project model by selecting Tools > Packages > Electric Imp > Create Model.

You can also select an existing model and associate the project with it by using the Tools > Packages > Electric Imp > Select Model menu item.

Important The code which is deployed to the model is preprocessed and contains line control markers. When you select a model, the plug-in pulls down the model’s code, but it doesn’t transfer the project file/folder structure. So for collaborative work on the same project, please share the original Electric Imp plug-in project sources/structure via a source control.

Logs Console

The Console can be popped up by selecting Tools > Packages > Electric Imp > Show Console menu item. The Console shows live logs from the model and the selected device.

Adding a Device to the Model

You can add other devices enrolled into your account to the project model by selecting Tools > Packages > Electric Imp > Add Device. The newly added device is automatically selected as the current one, which means the Console will show its logs.

Selecting a Device

Any device associated with the project model can be selected using the
Tools > Packages > Electric Imp > Select Device menu item. The selected device will used as a source of logs for the Console.

Removing a Device from the Model

Devices can be removed from the model by selecting Tools > Packages > Electric Imp > Remove Device.

NOTE: You can’t remove an active device (the one that is currently selected for logging).

Retrieving a Device’s Agent URL

The URL of a device’s agent can be retrieved by selecting the Tools > Packages > Electric Imp > Get Agent URL menu item. The URL is saved in the clipboard.

Key Shortcuts

Note Electric Imp-specific menu items are only available if an Electric Imp project is opened in the currently active window.

Command Keypress
Create Project Ctrl + Shift + Y
Build and Run Ctrl + Shift + X
Show Logs Console Ctrl + Shift + C

Preprocessor and Multi-File Support

Please refer to the Builder documentation for more information on the preprocessor syntax that you can use in your Squirrel code.

Specifying GitHub Authentication Information

Please use the project /settings/auth.info file to specify your Builder GitHub authentication information:

{
    ...
    "builder-settings": {
        "github-user": "GitHub user name", 
        "github-token": "Personal access token or password"
    }
}

Specifying Builder Preset Variable Definitions

Please use the project /settings/electric-imp.settings file to specify the Builder variables definitions:

{
    "builder-settings": {
        ...
        "variable-definitions": {
            "key1": "value1", 
            "key2": "value2"
        },
        ...
    }
}

License

The Electric Imp Sublime Plug-in is licensed under the MIT License.