def _on_connected(self, repl_view, port): repl_view.set_name("nREPL connected") repl_view.settings().set('nrepl_port', port) append_to_view(repl_view, (("; nREPL server started on port %d\n" + "; closing all REPL views using this port will kill the server\n") % port)) repl_view.window().run_command('clojure_eval', {'expr': '(str "These ones go up to " (inc 10))'})
def _on_done(self, resp): print "ClojureOutputToPanel resp\n", repr(resp) if resp.has_key('out'): panel = self.window.get_output_panel('eleven') append_to_view(panel, resp['out']) self.window.run_command("show_panel", {"panel": "output.eleven"}) else: sublime.status_message("No output for `%s`" % self.req['code'])
def _on_done(self, resp): print "ClojureOutputToView resp\n", repr(resp) view = self.window.new_file() view.set_scratch(True) view.set_read_only(True) view.set_name(self.req['code']) if self.args.has_key('syntax_file'): view.set_syntax_file(self.args['syntax_file']) append_to_view(view, resp['out']) view.sel().clear() view.sel().add(sublime.Region(0)) view.show(0)
def on_load(self, view): port = view.settings().get('nrepl_port') if port: # We're loading a REPL window that existed from a hot exit. Check # if nREPL is still running on that port. try: nrepl.NreplClient('localhost', port) print "nREPL on port %d is running" % port except: view.settings().set('nrepl_port', None) append_to_view(view, ("\n\n" + ";;;;;;;;;;;;;;;;\n" + "; DISCONNECTED ;\n" + ";;;;;;;;;;;;;;;;"))
def run(self): cwd = self.window.folders()[0] repl_view = self.window.new_file() repl_view.set_name("nREPL launching...") repl_view.set_scratch(True) repl_view.set_read_only(True) repl_view.settings().set('nrepl_port', 7999) #FIXME default or find an used one? repl_view.settings().set('nrepl_cwd', cwd) repl_view.settings().set('line_numbers', False) repl_view.set_syntax_file('Packages/Clojure/Clojure.tmLanguage') append_to_view(repl_view, ("; running `clj --nrepl-headless`%s...\n" % ("in " + cwd if cwd else ""))) thread.start_new_thread(self._start_server, (repl_view, cwd))
def _on_sent(self, req): region = append_to_view(self.repl_view, "\n\n%s\n" % req['code']) self.repl_view.add_regions(req['id'], [region], '')