Skip to content

Commit dfc458c

Browse files
committed
Automatically detect port from .nrepl-port (closes #5)
1 parent 5eac090 commit dfc458c

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

package.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,18 @@ def placeholder(self):
644644
return "host:port"
645645

646646
def initial_text(self):
647-
return conn.host + ":" + (str(conn.port) if conn.port else "")
647+
port = ''
648+
if conn.port:
649+
port = str(conn.port)
650+
window = sublime.active_window()
651+
if window:
652+
for folder in window.folders():
653+
if os.path.exists(folder + "/.nrepl-port"):
654+
with open(folder + "/.nrepl-port", "rt") as f:
655+
content = f.read(10).strip()
656+
if re.fullmatch(r'[1-9][0-9]*', content):
657+
port = content
658+
return conn.host + ":" + port
648659

649660
def initial_selection(self):
650661
return [(len(conn.host + ":"), len(self.initial_text()))]

script/nrepl.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66
subprocess.check_call(['clojure',
77
'-Sdeps', '{:deps {nrepl/nrepl {:mvn/version "0.8.3"}}}',
88
'-M', '-m', 'nrepl.cmdline',
9-
'--port', '5555'
9+
'--interactive'
1010
])

0 commit comments

Comments
 (0)