-
-
Save frou/7d2a5ca043be25e7c388be54a96987f2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
[ | |
{ | |
"caption": "Set Logging", | |
"command": "set_logging" | |
}, | |
{ | |
"caption": "Open Clojure REPL", | |
"command": "open_clojure_repl" | |
} | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"keys": ["alt+`"], | |
"command": "open_clojure_repl", | |
} | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sublime | |
import sublime_plugin | |
class SetLogging(sublime_plugin.ApplicationCommand): | |
CATEGORY_INPUT = "Input" | |
CATEGORY_COMMANDS = "Commands" | |
CATEGORY_BUILD_RESULTS = "Build Result Regexes" | |
CATEGORY_ALL = "<ALL CATEGORIES>" | |
CONTROL_FUNCTIONS = { | |
CATEGORY_INPUT: sublime.log_input, | |
CATEGORY_COMMANDS: sublime.log_commands, | |
CATEGORY_BUILD_RESULTS: sublime.log_result_regex, | |
} | |
def run(self, category, enabled): | |
try: | |
if category == self.CATEGORY_ALL: | |
for _, control_fn in self.CONTROL_FUNCTIONS.items(): | |
control_fn(enabled) | |
else: | |
control_fn = self.CONTROL_FUNCTIONS[category] | |
control_fn(enabled) | |
except KeyError: | |
sublime.error_message( | |
"{0}: Unexpected category: {1}".format( | |
self.__class__.__name__, category | |
) | |
) | |
def input(self, args): # noqa: A003 | |
return CategoryInputHandler() | |
class CategoryInputHandler(sublime_plugin.ListInputHandler): | |
def placeholder(self): | |
return "Select a category" | |
def list_items(self): | |
return [ | |
SetLogging.CATEGORY_ALL, | |
SetLogging.CATEGORY_INPUT, | |
SetLogging.CATEGORY_COMMANDS, | |
SetLogging.CATEGORY_BUILD_RESULTS, | |
] | |
def next_input(self, args): | |
return EnabledInputHandler() | |
def description(self, value, text): | |
return "of {0} to".format(text) | |
class EnabledInputHandler(sublime_plugin.ListInputHandler): | |
def list_items(self): | |
return [("On", True), ("Off", False)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# import sublime | |
import sublime_plugin | |
from .constants import CLJ, CLJS_BROWSER, CLJS_NODE | |
class OpenClojureRepl(sublime_plugin.TextCommand): | |
RLWRAP_CMD = ["rlwrap", "-r", "-p", "green", "-q", '"', "-b", "(){}[],^%#@\";:'"] | |
FLAVOUR_CMDS = { | |
CLJ: ["clojure"], | |
CLJS_BROWSER: ["clojure", "--main", "cljs.main"], | |
CLJS_NODE: ["clojure", "--main", "cljs.main", "--repl-env", "node"], | |
} | |
def run(self, edit, repl_flavour): | |
self.view.window().run_command("new_pane", {"move": False}) | |
self.view.window().run_command( | |
"terminus_open", | |
{ | |
"cwd": "${folder}", | |
"cmd": self.RLWRAP_CMD + self.FLAVOUR_CMDS[repl_flavour], | |
"title": repl_flavour + " REPL", | |
"tag": "REPL", | |
"auto_close": False, | |
}, | |
) | |
def input(self, args): | |
return ReplFlavourInputHandler() | |
class ReplFlavourInputHandler(sublime_plugin.ListInputHandler): | |
def placeholder(self): | |
return "Select a REPL flavour" | |
def list_items(self): | |
return [CLJ, CLJS_BROWSER, CLJS_NODE] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment