Skip to content

Commit

Permalink
Initial version
Browse files Browse the repository at this point in the history
  • Loading branch information
vojtajina committed Aug 17, 2012
0 parents commit 6c507cc
Show file tree
Hide file tree
Showing 6 changed files with 101 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Default (Linux).sublime-keymap
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[
{ "keys": ["super+b"], "command": "build_switcher" }
]
3 changes: 3 additions & 0 deletions Default (OSX).sublime-keymap
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[
{ "keys": ["super+b"], "command": "build_switcher" }
]
3 changes: 3 additions & 0 deletions Default (Windows).sublime-keymap
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[
{ "keys": ["super+b"], "command": "build_switcher" }
]
38 changes: 38 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# BuildSwitcher (Sublime Text 2 plugin)

Do you have multiple build systems per project ? This plugin will help you quickly execute the one you want.

## Instalation
Recommended way is using [PackageControll] package.

Or you can download the [tarball] and extract it to your `~/Library/Application Support/Sublime Text 2/Packages/BuildSwitcher`.

## Configuration
There is currently no way to get list of available build systems in [Sublime], so you need to explicitly specify the ones you wanna list. Just add into your `XXX.sublime-project` something like this:

````
{
"settings": {
"build_switcher_systems": ["Unit tests", "CoffeeScript"]
}
}
````

If you don't specify any build system, BuildSwitcher will just execute the currently selected build (the same behavior as Sublime's default `super+b` shortcut).

If you specify only one build system, it will execute it without asking.

If you specify multiple systems, you always get a pop up with options (sorted by usage).

## Defining key shortcut
By default, "build_switcher" is mapped to `CMD+B`, however you can easily change that, just add to your keymap preferences:

````
{ "keys": ["super+b"], "command": "build_switcher" }
````



[Sublime]: http://www.sublimetext.com/
[PackageControll]: http://wbond.net/sublime_packages/package_control/installation
[tarball]: https://github.com/vojtajina/sublime-BuildSwitcher/tarball/master
49 changes: 49 additions & 0 deletions build_switcher.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
from sublime_plugin import WindowCommand


class BuildSwitcherCommand(WindowCommand):

def __init__(self, window):
WindowCommand.__init__(self, window)

settings = self.window.active_view().settings()
settings.add_on_change("build_switcher_systems", self._reload_settings)
self._reload_settings()


def _reload_settings(self):
settings = self.window.active_view().settings()
self.available_systems = settings.get("build_switcher_systems")


def run(self):
win = self.window

if not self.available_systems:
# no switcher builds - just do selected build
win.run_command("build")
elif len(self.available_systems) is 1:
# only one build system - just run it
self._run_build(0)
else:
# more options, show the popup
win.show_quick_panel(self.available_systems, self._run_build)


def _run_build(self, idx):
# the dialog was cancelled
if idx is -1: return

self.window.run_command("set_build_system", {"file": self.available_systems[idx]})
self.window.run_command("build")

# move the last used system to first position
self.available_systems.insert(0, self.available_systems.pop(idx))


def is_enabled(self):
return True


def description(self):
return "Pop up a dialog with available build commands."
5 changes: 5 additions & 0 deletions package-metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"version": "0.0.1",
"url": "https://github.com/vojtajina/sublime-BuildSwitcher",
"description": "Bring a pop up to decide which build you wanna run."
}

0 comments on commit 6c507cc

Please sign in to comment.