LiveReload for Sublime Text

Plugins api

class PluginAPI.PluginClass[source]

Class for implementing your custom plug-ins, sublime_plugins compatible

Plug-ins implementing this reference should provide the following attributes:

  • description (string) describing your plug-in
  • title (string) naming your plug-in
  • file_types (string) file_types which should trigger refresh for this plug-in
addResource(req_path, blob, content_type='text/plain')[source]
  • (string) req_path; browser path to file you want to serve. Ex: /yourfile.js
  • (string/file) buffer; string or file instance to file you want to serve
  • (string) content_type; Mime-type of file you want to serve

Run plug-in only with this file extensions, defaults to all extensions


returns list with all connected clients with their req_url and origin


Runs when plug-in is disabled via menu


Runs when plug-in is enabled via menu

onReceive(data, origin)[source]

Event handler which fires when browser plug-ins sends data - (string) data sent by browser - (string) origin of data

refresh(filename, settings=None)[source]

Generic refresh command

  • (string) filename; file to refresh (.css, .js, jpg ...)
  • (object) settings; how to reload(entire page or just parts)
sendCommand(command, settings, filename=False)[source]
  • (instance) plug-in; instance
  • (string) command; to trigger in livereload.js (refresh, info, or one of the plugins)
  • (object) settings; additional data that gets passed to command (should be json parsable)
  • (string) original name of file

Returns True if specified filename is allowed for plug-in, and plug-in itself is enabled


Should it stay enabled forever or this session only


class LiveReload.LiveReload[source]

Bases: threading.Thread, server.SimpleCallbackServer.SimpleCallbackServer, server.SimpleWSServer.SimpleWSServer, server.SimpleResourceServer.SimpleResourceServer, server.LiveReloadAPI.LiveReloadAPI

Start the LiveReload, which exposes public api.


Stop the server.


Start LiveReload


Start the server.


Add http callback to plugin defined function. For example request to GET /callback/plugin_name/log_me would trigger log_me function in plugin


def compiled(self, req):
    print req # urlparse object
    return "cool" #to http client

Add websocket callback to plugin defined function. For example on function call in browser LiveReload.SM2.plugin_name.definedfunction(data) would trigger definedfunction function in plugin or vice verse. Shortly you can call client functions from the server and server functions from client. Everything is JSON encoded by default.


def compiled(self, json):
    print json # json object
    return "cool" #to http client {msg: "cool"}

Indices and tables